Solved

Catch error and RETRY? How?

Posted on 2008-10-06
4
315 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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

17 Experts available now in Live!

Get 1:1 Help Now