Solved

Catch error and RETRY? How?

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lock timeout/Deadlocks on a update query that updates the same column value 5 96
JDEdwards AP Batch 4 52
IBM 840 flash storage Array 3 186
iBM i DB2 Administration Training 6 107
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…
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…

791 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