Unit testing DDL statements that need to be in a transaction

删除回忆录丶 提交于 2019-12-02 11:01:06

You should use Oracle proxy authentication in combination with row level security.

Read this: http://www.oracle.com/technology/pub/articles/dikmans-toplink-security.html

First off I have to say: bad idea doing it this way. For two reasons:

  1. Connections are based on user. That means you largely lose the benefits of connection pooling. It also doesn't scale terribly well. If you have 10,000 users on at once, you're going to be continually opening and closing hard connections (rather than soft connection pools); and
  2. As you've discovered, creating and removing users is DDL not DML and thus you lose "transactionality".

Not sure why you've chosen to do it this but I would strongly recommend you implement users at the application and not the database layer.

As for how to solve your problem, basically you can't. Same as if you were creating a table or an index in the middle of your sequence.

I'll disagree with some of the previous comments and say that there are a lot of advantages to using the built-in Oracle account security. If you have to augment this with some sort of shadow table of users with additional information, how about wrapping the Oracle account creation in a separate package that is declared PRAGMA AUTONOMOUS_TRANSACTION and returns a sucess/failure status to the package that is doing the insert into the shadow table? I believe this would isolate the Oracle account creation from the transaction.

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