Reputation: 641
I have a package which I call like this:
BEGIN
package.sp1();
package.sp2();
END;
During this execution, a table is updated in procedures sp1 and sp2. However, I need to store a copy of that table as it was originally just in case something goes wrong and I need to restore the previous data. The data would only be copied on the first execution of each day. Then, the next day, the copied data would be used as a starting point to be updated in procedures sp1 and sp2.
How can I do that in another procedure?
This is what I want to do in pseudo-code:
BEGIN
-- Fetch the data copied in yesterday's first execution
package.sp1(); -- Updates the table
package.sp2(); -- Also updates the table
-- Store the updated data if this is the first execution of the day
END;
Upvotes: 0
Views: 146
Reputation: 65433
You can leave it turning back to the previous day's data to the Oracle's Flashback Query mechanism provided that the version your database is 10g+ along with some conditions satisfied such as
Then use this query ;
DELETE tab;
INSERT INTO tab
SELECT *
FROM tab
AS OF TIMESTAMP TRUNC(SYSTIMESTAMP);
COMMIT;
whenever something went wrong and needed to come back to the point in time for the data.
Upvotes: 1