Timeout for speficic query inside stored procedure [message #176274] |
Wed, 07 June 2006 11:40  |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
Hello,
I currently work on a application that needs data for some items.
The communication between the frontend and Oracle is implemented via stored procedures. The application has to be as responsive as possible. The information that is essential is selected in fractions of seconds, no problem there.
The data for the Items als contains some "nice to have" information, that is just displayed for informational purposes, for example the numer of open orders for one item. That usually is also selected in under one second. (According to the explained plan the appropriate indexes are used, etc ...)
But every now and then at that point (get open orders) the query takes longer than the application SQL timeout, hence resulting in an "ORA-01013 User requested cancel of the current operation" on the client side.
Is there any way to specify a specific timeout just for that SELECT Sum(itemcount)... part inside the stored procedure, so that if the query is not finished within, for example, 2 seconds 0 is returned? That way the remaining data would still be available.
Example code :
-- procedure to get item data;
CREATE OR REPLACE PROCEDURE get_item_data (item_no IN NUMBER,
item_name OUT VARCHAR2,
open_orders OUT number)
IS
BEGIN
-- get all the base data. No problems here.
item_name := 'Test';
-- get open orders. This times out every now and then.
SELECT Sum(itemcount)
INTO open_orders
FROM orders
WHERE status = 'O';
END;
Does anyone have any ideas in that direction? I really don't want to change it to two seperate calls on the client side. 
|
|
|
Re: Timeout for speficic query inside stored procedure [message #176320 is a reply to message #176274] |
Wed, 07 June 2006 19:29   |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
If this was a web app it would be quite trivial, because you can have multiple components to the page - each with it's own async call to the server(s).
I would try defining 2 different connections - but pointing to the same database, fast response calls get set to connection1 and slow to connection2. This the issue is limited to you'r apps ability to display both results asynchronusly...
If you really wanted a round about way, you could submit a dbms_job to fetch the dat into a "temp" table and then poll for those results from using a "session id". Probably not very scalable...
|
|
|
Re: Timeout for speficic query inside stored procedure [message #176422 is a reply to message #176320] |
Thu, 08 June 2006 05:03  |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
Well, unfortunately the client app is running locally on different devices, including some mobiles. The procedure might even be used in some custom applications written by someone else that we are not aware off.
I've pondered selecting the stuff in an extra Java stored procedure, but .setQueryTimout doesn't work server side according to some bugs and feature requests at metalink.
So I will sleep another couple of nights over it and then maybe have a look at the dbms_job approach.
|
|
|