DB2 z/OS Calling DSNTIAR from DSNREXX

Don Leahy

DB2 z/OS Calling DSNTIAR from DSNREXX
From time to time I have seen questions posted on this topic, and various
solutions have been offered. Most, if not all of them involve some pretty
hairy looking code such as:

if length(sqlerrd.4) > digits() then numeric digits length(sqlerrd.4)

SQLC = D2X(SQLCODE,8)
SQLC = X2C(SQLC)
SQLCA = 'SQLCA 'X2C(00000088)SQLC||X2C(RIGHT(LENGTH(SQLERRM),4,'0')),
||LEFT(SQLERRM,70,' '),
||LEFT(SQLERRP,8,' ')

SQLCA = SQLCA||x2c(d2x(sqlerrd.1,8)) || x2c(d2x(sqlerrd.2,8)) ,
||x2c(d2x(sqlerrd.3,8)) || x2c(d2x(sqlerrd.4,8)) ,
||x2c(d2x(sqlerrd.5,8)) || x2c(d2x(sqlerrd.6,8)) ,
||copies(' ',10) ,
||right(sqlstate,5,'0')

TIAR_MSG = X2C(0320)COPIES(' ',800)
TEXT_LEN = X2C(00000050)

ADDRESS ATTCHPGM 'DSNTIAR SQLCA TIAR_MSG TEXT_LEN'

say SUBSTR(TIAR_MSG,4,LENGTH(TIAR_MSG) - 4)

I've used the code fragment above, which does work, but I've never been very
happy about it.

I've often wished that IBM had supplied a simple callable function that
would return the DSNTIAR message without having to go through a lot of
gyrations.

A few years back I wrote such a function and have been using it ever since.
I no longer need all of that code in my DSNREXX functions. It has been
reduced to:

ADDRESS LINK "RXSQLCA"
say SQLERRMSG

I have posted RXSQLCA in the Code Place at www.idug.org. It has also been
posted on IBM's "Examples" web page:

http://www.ibm.com/support/docview.wss?rs=64&uid=swg27008711

Please feel free to use it, or not, as you see fit. It has been tested with
DB2 V7, but has never been used with V8.

---------------------------------------------------------------------------------
Welcome to the IDUG DB2-L list. To unsubscribe, go to the archives and home page at http://www.idugdb2-l.org/archives/db2-l.html. From that page select "Join or Leave the list". The IDUG DB2-L FAQ is at http://www.idugdb2-l.org. The IDUG List Admins can be reached at [login to unmask email] Find out the latest on IDUG conferences at http://conferences.idug.org/index.cfm

Don Leahy

DB2 z/OS Calling DSNTIAR from DSNREXX
(in response to Don Leahy)
From time to time I have seen questions posted on this topic, and various solutions have been offered. Most, if not all of them involve some pretty hairy looking code such as:

if length(sqlerrd.4) > digits() then numeric digits length(sqlerrd.4)

SQLC = D2X(SQLCODE,8)
SQLC = X2C(SQLC)
SQLCA = 'SQLCA 'X2C(00000088)SQLC||X2C(RIGHT(LENGTH(SQLERRM),4,'0')),
||LEFT(SQLERRM,70,' '),
||LEFT(SQLERRP,8,' ')

SQLCA = SQLCA||x2c(d2x(sqlerrd.1,8)) || x2c(d2x(sqlerrd.2,8)) ,
||x2c(d2x(sqlerrd.3,8)) || x2c(d2x(sqlerrd.4,8)) ,
||x2c(d2x(sqlerrd.5,8)) || x2c(d2x(sqlerrd.6,8)) ,
||copies(' ',10) ,
||right(sqlstate,5,'0')

TIAR_MSG = X2C(0320)COPIES(' ',800)
TEXT_LEN = X2C(00000050)

ADDRESS ATTCHPGM 'DSNTIAR SQLCA TIAR_MSG TEXT_LEN'

say SUBSTR(TIAR_MSG,4,LENGTH(TIAR_MSG) - 4)

I've used the code fragment above, which does work, but I've never been very happy about it.

I've often wished that IBM had supplied a simple callable function that would return the DSNTIAR message without having to go through a lot of gyrations.

A few years back I wrote such a function and have been using it ever since. I no longer need all of that code in my DSNREXX functions. It has been reduced to:

ADDRESS LINK "RXSQLCA"
say SQLERRMSG

I have posted RXSQLCA in the Code Place at www.idug.org. It has also been posted on IBM's "Examples" web page (beware of wrap):

http://www.ibm.com/support/docview.wss?rs=64&uid=swg27008711

Please feel free to use it, or not, as you see fit. It has been tested with DB2 V7, but has never been used with V8.

---------------------------------------------------------------------------------
Welcome to the IDUG DB2-L list. To unsubscribe, go to the archives and home page at http://www.idugdb2-l.org/archives/db2-l.html. From that page select "Join or Leave the list". The IDUG DB2-L FAQ is at http://www.idugdb2-l.org. The IDUG List Admins can be reached at [login to unmask email] Find out the latest on IDUG conferences at http://conferences.idug.org/index.cfm