Description of SQL error.

RDBMS from IBM.
Previous topicNext topic

Topic Author
Bethany
Registered Member
Posts: 10
Joined: Sat Dec 28, 2013 2:57 pm

Description of SQL error.

Post by Bethany » Wed Apr 05, 2017 2:31 pm

Hi,

If any SQL error occured during run of any batch program, where can we check complete message for that SQL code. What I am asking is that is there a place in logs where it will give position of column where problem is, is there any variable which stores such message?



User avatar

Anuj Dhawan
Founder
Posts: 2612
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: Description of SQL error.

Post by Anuj Dhawan » Wed Apr 05, 2017 4:58 pm

Unless 'am mistaken you are looking for DSNTIAR. DSNTIAR is an assembler subroutine and helps you to obtain a formatted form of the SQLCA and a text message that is based on the SQLCODE field of the SQLCA. Said that, I've presumed you are using SQLCA in your COBOL-DB2 code. A typical output from DSNTIAR will look like this:

Code: Select all

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
Hope this helps.


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.


Topic Author
Bethany
Registered Member
Posts: 10
Joined: Sat Dec 28, 2013 2:57 pm

Re: Description of SQL error.

Post by Bethany » Thu Apr 06, 2017 10:30 pm

Thanks Anuj. Can you please help with some good example of it which I can use as a reference please?



User avatar

Anuj Dhawan
Founder
Posts: 2612
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: Description of SQL error.

Post by Anuj Dhawan » Thu Apr 06, 2017 10:39 pm

A google search could have also helped you: A scenario for using DSNTIAR.


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.


Topic Author
Bethany
Registered Member
Posts: 10
Joined: Sat Dec 28, 2013 2:57 pm

Re: Description of SQL error.

Post by Bethany » Fri Apr 07, 2017 11:54 am

Thank you so much Anuj.

Google helps more the experinced people like you :)



Previous topicNext topic

Return to “IBM DB2.”