IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

INITIALIZE SQLCODE - what does this do in Cobol DB2 program


IBM Mainframe Forums -> ABENDS & Debugging
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Tue May 12, 2009 1:36 pm
Reply with quote

hi all,

can anyone tell me what does this statement 'INITIALIZE SQLCODE' do in a cobol-db2 program.

it is placed just before any SQL query (EXEC SQL) in program.

thanks
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue May 12, 2009 2:50 pm
Reply with quote

INITIALIZE SQLCODE will populate the field, SQLCODE, with zero.

It just shows that the coder does not understand DB2.

He probably got burnt checking the SQLCODE after a DECLARE Cursor and did not learn anything.
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Tue May 12, 2009 3:00 pm
Reply with quote

Thanks.

probably you are right. the coder might not undersatnd DB2.
And this is the way one learns.

but this may be true that the coder got to know about the statement from some where and tries to find out its usage.

Using INITIALIZE SQLCODE before each SQL query, moves LOW-VALUES to SQLCODE. This avoids garbage value in the variable.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue May 12, 2009 4:34 pm
Reply with quote

were you trying to say something with your 'bold' font?

Quote:
Using INITIALIZE SQLCODE before each SQL query, moves LOW-VALUES to SQLCODE.

It populates the COMP field, SQLCODE, with binary zeroes.

Which are often interpreted as low-values in a COMP field
by those overwhelmed and challanged by technical terms
or incapable of being precise.

LOW-VALUES is an alphanumeric figurative constant
and as such, can not be MOVED to a COMP field, ya' gotta move the
NUMERIC figurative constant - ZERO.
(sorry about my 'boldness', but it is a rather important distinction.

Quote:
This avoids garbage value in the variable.

which only has a meaning if some idiot checks the SQLCODE before a CALL to 'db2', (or after a DECLARE Cursor).
DB2 always populates the SQLCODE during a CALL to a DB2 service invoked by SQL.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue May 12, 2009 8:28 pm
Reply with quote

Hello,

Quote:
which only has a meaning if some idiot checks the SQLCODE before a CALL to 'db2', (or after a DECLARE Cursor).
And if this has been done, it should probably be removed lest it confuse someone as actually having some worth. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> ABENDS & Debugging

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top