?
Solved

Count records...

Posted on 2014-02-17
5
Medium Priority
?
475 Views
Last Modified: 2014-02-18
Hi,
I developed DB in ORACLE 11g XE and since there is a limitation (11GB), the DB is keeping only the records with certain criteria. The records are deleted (with stored procedure) once in a day (23:59)...
The client requested to have statistics / reports on the records.
I think that it will be the best solution to count the deleted records and write the count in one table with time stamp... Can someone help me?
Thank you in advance,
Best,
Andreja
0
Comment
Question by:andrejaTJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 39864894
Perhaps you could persuade your client to PURCHASE at minimum the Standard edition.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 932 total points
ID: 39864900
directly after the delete, use SQL%ROWCOUNT value.
this would be the pl/sql draft to start with:
DECLARE 
  v_rows NUMBER;
BEGIN
DELETE yourtable WHERE .... ;
  v_rows := SQL%_ROWCOUNT;
 INSERT INTO your_log_table ( datetime, rows_deleted ) VALUES ( SYSDATE, v_rows);
 COMMIT;
END; 

Open in new window

0
 

Author Comment

by:andrejaTJ
ID: 39864914
Thank you for your prompt reply.
But the "DELETE yourtable WHERE" is not applicable here...
Can you please help me without the "DELETE yourtable WHERE"?I will schedule job prior the one that is calling the DELETE stored procedure...
Thank you,
Best,
Andreja
0
 
LVL 29

Assisted Solution

by:MikeOM_DBA
MikeOM_DBA earned 468 total points
ID: 39864927
You may need to add Guy's suggested code inside the DELETE stored procedure.
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 932 total points
ID: 39864935
exactly.
you cannot count "outside" the stored procedure on how many records you deleted exactly.

well, you COULD do the count of the records to be deleted using the same condition the stored procedure is doing, but then you will just waste db power to do 2 times the same thing.
you COULD also counter the number of records in the table before and after the procedure, but this will give erroneous results if during that time, new records are added.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question