Oracle SQL, how to access latest queries and their data

oracle

I have SQL Developer, + Oracle client 11g.

I wrote a program (MFC Visual C++) that read and writes data to a certain table.
usually i put logs in the project so I could see what I insert/Update/Delete from the table.
Now I am about to delete multiple rows. and I would like to count the lines I deleted.

How can I know the latest queries that used in the DB, what they affected and get some data on activities that were held on the server ?

thanks !

Best Answer

To count the rows deleted just after the delete statement use SQL%ROWCOUNT. Here is a demonstration.

--Setup.
drop table t1;
create table t1 as (select level x from dual connect by level <=5);

set serveroutput on size 1000000 format wrapped
DECLARE
   vCount Number(3);
BEGIN
   DELETE FROM T1 WHERE rownum<=2;
   vCount := SQL%ROWCOUNT;  --<<---<<---<<---<<---<<---<<---<<---<<---
   DBMS_Output.Put_Line('RowCount:' || vCount);
END;
/

For your broader question you can look into tracing, auditing, flashback database, flashback query, logminer, materialized views, streams, and change data capture (not necessarily in that order). We would need more details about what data you need and why before directing you any more specifically.