Improve company productivity with a Business Account.Sign Up

x
?
Solved

Catch error and RETRY? How?

Posted on 2008-10-06
4
Medium Priority
?
324 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

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 (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…

595 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