View previous topic :: View next topic |
Author |
Message |
grimpeur Beginner
Joined: 10 Jul 2006 Posts: 16 Topics: 5
|
Posted: Fri Aug 15, 2008 11:16 am Post subject: Rexx/DB2 Error Handling |
|
|
Hi,
I am bringing myself up to speed with Rexx/DB2 appl. programming and have a query regarding error message handling.
If I get a negative SQL code in my program I would like to display the meaningful DB2 error message, such as:-
-904 UNSUCCESSFUL EXECUTION CAUSED BY AN UNAVAILABLE RESOURCE. REASON 00C90081, TYPE OF RESOURCE 00000210, AND RESOURCE NAME DDBDATA .SDBTS1 .00000001
I can display the content of SQLERRMC, but this just gives me the variable parts of the above message (reason-code, resource-type and resource-name), as follows...
00C90081:00000210:DDBDATA .SDBTS1 .00000001
Is there a technique for generating the entire message complete with meaningful text?
Apologies if I missed something obvious - I haven't used Rexx much at all so please be gentle!
Thanks! |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Fri Aug 15, 2008 11:35 am Post subject: |
|
|
grimpeur,
The table partition DDBDATA .SDBTS1 .00000001 is stopped. You need to find out the reason as to why the partition is stopped
Kolusu |
|
Back to top |
|
|
grimpeur Beginner
Joined: 10 Jul 2006 Posts: 16 Topics: 5
|
Posted: Fri Aug 15, 2008 1:32 pm Post subject: |
|
|
Sorry for any confusion - I stopped the TS deliberately to simulate an error.
My question is can I get from anywhere the full text of the error message (in this case "-904 UNSUCCESSFUL EXECUTION CAUSED BY AN UNAVAILABLE RESOURCE.... etc etc...") rather than just the variable parts of it, so that this can be displayed/output as a meaningful error message when the program abends?
At the moment, I only seem to be able to display the variable parts, ie 00C90081:00000210:DDBDATA .SDBTS1 .00000001 which represent the reason-code, resource-type and resource-name. However this is not that great without the full text of the -904 message.
It's not just -904s I'm concerned about - I would like to provide a full error message with text and variables merged together when the prog ends.
Should I have posted this in the Application Programming fourm?
Thanks again. |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Fri Aug 15, 2008 2:03 pm Post subject: |
|
|
Not 100% certain on this but I think you would have to hardcode all the error messages in your rexx program and have an error routine that will complete the message before displaying it. I always found that the return code and reason code were sufficient but I was only using one table at a time. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Fri Aug 15, 2008 3:38 pm Post subject: |
|
|
I think if you return the contents of SQLCA.SQLMSG you can return the error message you have shown above. |
|
Back to top |
|
|
Terry_Heinze Supermod
Joined: 31 May 2004 Posts: 391 Topics: 4 Location: Richfield, MN, USA
|
Posted: Sat Aug 16, 2008 12:52 am Post subject: |
|
|
Can I assume that REXX cannot call 'DSNTIAR' like COBOL can? _________________ ....Terry |
|
Back to top |
|
|
grimpeur Beginner
Joined: 10 Jul 2006 Posts: 16 Topics: 5
|
Posted: Sat Aug 16, 2008 3:52 am Post subject: |
|
|
Hardcoding all the possible error messages is not a realistic option. I'm amazed there isn't an obvious way of doing this!
Thanks for the responses though... I tried displaying SQLCA.SQLMSG but could not get that to work - also I couldn't find any reference to SQLMSG in the manual.
Will investigate use of DSNTIAR but would welcome any further comments in the meantime.
Thanks. |
|
Back to top |
|
|
IEFBR14 Beginner
Joined: 13 Aug 2008 Posts: 17 Topics: 0 Location: SYS1.LINKLIB
|
Posted: Mon Aug 18, 2008 10:51 am Post subject: |
|
|
You can call DSNTIAR from Rexx |
|
Back to top |
|
|
grimpeur Beginner
Joined: 10 Jul 2006 Posts: 16 Topics: 5
|
Posted: Mon Aug 18, 2008 2:17 pm Post subject: |
|
|
Thanks IEFBR14 I will look into that (unless anybody has a code snippet they would be willing to share ) |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Aug 18, 2008 3:57 pm Post subject: |
|
|
untested code collected from the net
Code: |
/ * REXX */
PARSE UPPER ARG SQLCODE UPPER PARSE ARG SQLCODE
SQLC = D2X(SQLCODE,8) SQLC = D2X (SQLCODE, 8)
SQLC = X2C(SQLC) SQLC = X2C (SQLC)
SQLCA = 'SQLCA ' SQLCA = 'SQLCA'
SQLCA = SQLCA !! SQLCA = SQLCA! X2C(00000088) X2C (00000088)
SQLCA = SQLCA !! SQLCA = SQLCA! SQLC SQLC
SQLCA = SQLCA !! SQLCA = SQLCA! X2C(0000) X2C (0000)
SQLCA = SQLCA !! SQLCA = SQLCA! COPIES(' ',78) COPIES ( '', 78)
SQLCA = SQLCA !! SQLCA = SQLCA! COPIES(X2C(00),24) COPIES (X2C (00), 24)
SQLCA = SQLCA !! SQLCA = SQLCA! COPIES(' ',16) COPIES ( '', 16)
TIAR_MSG = X2C(0190)COPIES(' ',400) TIAR_MSG = X2C (0190) COPIES ( '', 400)
TEXT_LEN = X2C(00000050) ; TEXT_LEN = X2C (00000050);
ADDRESS ATTCHPGM 'DSNTIAR SQLCA TIAR_MSG TEXT_LEN' ADDRESS ATTCHPGM 'DSNTIAR SQLCA TIAR_MSG TEXT_LEN'
SAY SUBSTR(TIAR_MSG,4,400); SAY SUBSTR (TIAR_MSG, 4.400);
|
You can also check this out
http://www.ibm.com/developerworks/exchange/dw_entryView.jspa?categoryID=27&externalID=287 |
|
Back to top |
|
|
|
|