Solved

Catch error and RETRY? How?

Posted on 2008-10-06
4
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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