问题
To test some database pieces of a work project, I decided test it using triggers due to a nightly job.
The nightly job
- Wipes everything from temporary tables
- repopulates those tables from an outside database
- merges the temp tables into primary tables
- a couple other jobs
For the purposes of these tests I am not inclined to alter the source databases, but as the nightly job wipes the tables I cant just put values in which would work for my tests.
Due to the load processes, once they are finished a trigger is fired which alters the data in that table.
My problem is that I now want the triggers to perform a DDL statement (which commits) but also not have it PRAGMA AUTONOMOUS_TRANSACTION. The DDL statements either turn off the initial trigger (so it will only fire once) or activate the trigger that will clean up the test results the next time the nightly job runs (such as when triggered manually).
I do not want to make it PRAGMA AUTONOMOUS_TRANSACTION because in a different transaction means the nightly job and the triggers jobs wont see each other, and so the purpose of the tests cant be done, for example, adding a new employee, or a name change.
来源:https://stackoverflow.com/questions/57400844/how-can-a-trigger-perform-a-ddl-statement-without-pragma-autonomous-transaction