I have a program which executes sql statements. Within a transaction, I’d like to update several tables using the same sysdate.
eg. (run the following 3 statements in a transaction)
update table1 set some_col = 'updated' where some_other_col < sysdate;
delete from table2 where some_col < sysdate;
insert into table3 (col1, col2) select c1, c2 from table4 where some_col < sysdate;
If these 3 statements are executed in a transaction, the “sysdate” each one is using will be whatever timestamp we are at currently as this statement is running, not at the start of the transaction.
I could create a stored procedure and initially select the sysdate into a variable, using PL/SQL, but I’d prefer to just run sql statements from an external program.
Use an anonymous block instead of a stored procedure, something like (untested):