如何在 plsql 中为匿名块或查询设置超时?

2021-12-30 00:00:00 sql oracle11g oracle plsql

我知道您可以设置用户个人资料或设置查询的一般超时.>

但我希望为过程中的特定查询设置超时并捕获异常,例如:

开始更新 tbl 设置 col = v_val;--无限时间从 id = 20 的 tbl 中删除;--无限时间开始从 tbl 中删除;-- 我希望这有一个有限的时间来执行异常(超时???)然后- 代码;结尾;结尾;

这可能吗?我能捕捉到任何超时异常吗?每个块或查询?没有找到关于该主题的太多信息.

解决方案

不,您不能在 pl/sql 中设置超时.您可以为此使用宿主语言,在其中嵌入 sql 和 pl/sql.

I know you can set user profiles or set a general timeout for query.

But I wish to set timeout to a specific query inside a procedure and catch the exception, something like :

begin
      update tbl set col = v_val; --Unlimited time
      delete from tbl where id = 20; --Unlimited time

      begin
            delete from tbl; -- I want this to have a limited time to perform
            exception  when (timeout???) then
            --code; 

      end;

end;

Is this possible? is there any timeout exceptions at all I can catch? per block or query? didn't find much info on the topic.

解决方案

No, you can not set a timeout in pl/sql. You could use a host language for this in which you embed your sql and pl/sql.

相关文章