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.
Using SQL Server Management StudioIn Object Explorer, right-click a server and select Properties. Click the Connections node. Under Remote server connections, in the Remote query timeout box, type or select a value from 0 through 2,147,483,647 to set the maximum number seconds for SQL Server to wait before timing out.
The PL/SQL anonymous block statement is an executable statement that can contain PL/SQL control statements and SQL statements. It can be used to implement procedural logic in a scripting language. In PL/SQL contexts, this statement can be compiled and executed by the data server.
Execute a PL/SQL anonymous block using SQL*Plus Second, turn on the server output using the SET SERVEROUTPUT ON command so that the DBMS_OUTPUT. PUT_LINE procedure will display text on the screen. Third, type the code of the block and enter a forward slash ( / ) to instruct SQL*Plus to execute the block.
Try using the WAITFOR command in T-SQL. That'll pause the execution of the query and you should see a timeout. Try using the WAITFOR command in T-SQL. That'll pause the execution of the query and you should see a timeout.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With