Solved

Catch error and RETRY? How?

Posted on 2008-10-06
4
314 Views
Last Modified: 2010-05-18
I have an MQT.
I need to execute ........... REFRESH TABLE MyLIB.MyMQT
If a client application "HAPPENS" to be accessing the same MQT ... I get error

SQL State: 57033
Vendor Code: -913
Message: [SQL0913] Row or object IPCUTMQ0 in CSIDEV type *FILE in use. Cause . . . . . :   The requested object IPCUTMQ0 in CSIDEV type *FILE is either in use by another application process or a row in the object is in use by either another application process or another cursor in this application process.

How would I write a SQL script to capture the error and re-try the REFRESH TABLE MyLIB.MyMQT again?
Maybe even keep trying for 1 minute or 5 attempts or some such repeat threshold?

0
Comment
Question by:volking
  • 2
  • 2
4 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
ID: 22657023
you just need to perform a simple loop
for example

while (SQLCODE<>0) DO
    refresh table...
end while

but note that this might get you into an infinite loop if you get some kind of error that can not be fixed for example if you wrote a wrong mqt name, the mqt is invalid etc...
maybe you should modify it to SQLCODE <> -913

0
 
LVL 5

Author Comment

by:volking
ID: 22659199
@Momi - something like this .... right?

---------------------------------
    DECLARE SQLCODE INTEGER DEFAULT 0;
    DECLARE TRYS INTEGER DEFAULT 0;
    SET TRYS = 4;
    WHILE TRYS > 0 DO
        REFRESH TABLE MyLib.MyMQT ;
        IF ((SQLCODE = 0) OR (SQLCODE>0 and SQLCODE <> 100)) THEN
            SET TRYS = 0;
        ELSE
            SET TRYS = TRYS - 1;
        END IF;
    END WHILE;
0
 
LVL 5

Author Comment

by:volking
ID: 22659240
Criteria used was based on documentation which says .....

The SQLCODE is also set by the database manager after each SQL statement is executed as follows:
- If SQLCODE = 0 and SQLWARN0 is blank, execution was successful.
- If SQLCODE = 100, no data was found. For example, a FETCH statement returned no data, because the cursor was positioned after the last row of the result table.
- If SQLCODE > 0 and not = 100, execution was successful with a warning.
- If SQLCODE = 0 and SQLWARN0 = 'W', execution was successful with a warning.
- If SQLCODE < 0, execution was not successful.
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 22666578
your code looks fine (assuming there are no warning you need to consider)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now