Calling DSNTIAR to display SQLCA fields

 If you're using DB2-COBOL, you're bound to have obtained something similar to the following in the spool: 

DSNT408I SQLCODE = -501, ERROR: THE CURSOR IDENTIFIED IN A FETCH OR CLOSE STATEMENT IS NOT OPEN 

followed by more details about why the DB2 operation failed. It could be anything: like timeout, deadlock message etc. 

CALL 'DSNTIAR' USING SQLCA 
                                             WT-DSNTIAR-ERROR-TABLE 
                                            WT-DSNTIAR-ERROR-TEXT-LENGTH. 

Hmm....you may wonder, "i never code such a line in my COBOL code!" Well we usually just copy paste the error routine. You might use a common ABEND-para. And this abend-para might be coded in another copylib. If you locate this copylib you'll find the above statement.

So, whenever we have a SQL problem, we call this abend para, which in turn calls the DSNTIAR routine which inturn uses the SQLCA structure to decode the sqlcode+other error numbers to produce a text message in our spool. The message might be something like below: 

DSNT408I SQLCODE = -501, ERROR: THE CURSOR IDENTIFIED IN A FETCH OR
CLOSE STATEMENT IS NOT OPEN
DSNT418I SQLSTATE = 24501 SQLSTATE RETURN CODE
DSNT415I SQLERRP = DSNXERT SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD = -315 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD = X'FFFFFEC5' X'00000000' X'00000000'
X'FFFFFFFF' X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION 

Notice all the messages begin with a "DSNT"! 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值