Solved

Count records...

Posted on 2014-02-17
5
472 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 233 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 117 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 233 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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 configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

726 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