How can a trigger perform a DDL statement without PRAGMA AUTONOMOUS_TRANSACTION?

夙愿已清 提交于 2019-12-24 19:54:23

问题


To test some database pieces of a work project, I decided test it using triggers due to a nightly job.

The nightly job

  1. Wipes everything from temporary tables
  2. repopulates those tables from an outside database
  3. merges the temp tables into primary tables
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!