Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SQLCODE 000000031J On Prepare statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ballalsachin

New User


Joined: 22 Sep 2005
Posts: 15
Location: USA

PostPosted: Wed Dec 02, 2009 4:59 pm    Post subject: SQLCODE 000000031J On Prepare statement
Reply with quote

Hi,

I am trying to execute a cobol-db2 program having Dynamic SQL.
here is what I did
1. Declared
01 STRING-VAR-TXT.
49 STRING-VAR-LEN PIC S9(4) USAGE COMP.
49 STRING-QUERY PIC X(9000).

2. prepared the query in STRING0-VAR-TXT using String statements.
Number of columns i am fetching are constant. Query is a Simple select query with 13-15 where clauses, concatenated with 'AND'

3. Declared a Cursor using
EXEC SQL
DECLARE CSR CURSOR FOR FLSQL
END-EXEC.
Displayed the SQLcode after declaring the cursor. it is 00

4. prepared the statement using
EXEC SQL
PREPARE FLSQL FROM :STRING-VAR-TXT
END-EXEC.
displayed the SQLCODE of SQLCA; it is coming out to be 000000031J

just wondering what this code means. I am not being able to fetch the values using this cursor.
I tried to display the query which is constructed in the varchar. It seems to be correct.

Can someone please help ?

Thanks
Sachin
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Wed Dec 02, 2009 5:05 pm    Post subject: Reply to: SQLCODE 000000031J On Prepare statement
Reply with quote

31j is the zoned representation of a negative number

Code:

  number     printable      hex
  +0         {              C0             
  +1         A              C1             
  +2         B              C2             
  +3         C              C3             
  +4         D              C4             
  +5         E              C5             
  +6         F              C6             
  +7         G              C7             
  +8         H              C8             
  +9         I              C9             

  -0         }              D0             
  -1         J              D1             
  -2         K              D2             
  -3         L              D3             
  -4         M              D4             
  -5         N              D5             
  -6         O              D6             
  -7         P              D7             
  -8         Q              D8             
  -9         R              D9             


use the proper process to display correctly a negative number
given the above look for the meaning of a -311 sql code
Back to top
View user's profile Send private message
ballalsachin

New User


Joined: 22 Sep 2005
Posts: 15
Location: USA

PostPosted: Wed Dec 02, 2009 5:27 pm    Post subject:
Reply with quote

Thanks Enrico,

Appears to me that the length of host variable is a problem. Will dig down and let you know if the SQL works.

Appreciate your response.

Thanks
Sachin
Back to top
View user's profile Send private message
ballalsachin

New User


Joined: 22 Sep 2005
Posts: 15
Location: USA

PostPosted: Fri Dec 04, 2009 4:27 pm    Post subject: Reply to: SQLCODE 000000031J On Prepare statement
Reply with quote

Subsequent to this, I wrote my query into the file and after inspection, made some corrections.

Now after prepare statement i am getting SQLCODE as 000000010M.
I assume this is SQLCODE -104.

The descripton of this errorcode is not very helpful in the Quickref:
ILLEGAL SYMBOL "token". SOME SYMBOLS THAT MIGHT BE LEGAL ARE:
token-list

Can someone help me with what might the problem be ?

I tried executing the query that i build using a SPUFI, and it works.

Thanks
Sachin Ballal
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Dec 04, 2009 5:42 pm    Post subject:
Reply with quote

Quote:
I tried executing the query that i build using a SPUFI, and it works.


well since spufi is 'static' sql when compared to your program dynamic sql,
you comment is just worthless.

and Quickref is exactly that, it is an abbreviated reference to be used
by those who have spent a couple of minutes reading the complete reference.

since you seemed to be manually challanged and only like to use quick references use IBM LookAt Site
it is the same as quickref
(actually it is better,
tailored for someone like you,
you only have to enter the error code,
you don't have to know what you were trying to do before receiving the error,
and it provides links to error msg manuals - yes they exist).
Back to top
View user's profile Send private message
ballalsachin

New User


Joined: 22 Sep 2005
Posts: 15
Location: USA

PostPosted: Fri Dec 18, 2009 11:12 am    Post subject:
Reply with quote

When I said - I tried executing the query that i build using a SPUFI, and it works. - it meant there was not problem in the syntax of the query whatsoever.

Because the production version of my program is a CICS program, i do not have a luxury of displying what the query looks like - after 30 string statements.. So i wrote it into a file and tried executing that query using a spufi. .. anyways. Thanks for your help.

I figured out myself, that there was a problem with '<>' symbol. I was initially writing '¬=' by mistake. Another problem was - the length of the query in VARCHAR should be exactly equal to the length of the query.

Cheers
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Dec 18, 2009 9:34 pm    Post subject: Reply to: SQLCODE 000000031J On Prepare statement
Reply with quote

Good to hear this is working - thank you for posting the solution icon_smile.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 SQL Error: SQLCODE=-440, SQLSTATE... kishpra DB2 1 Sat Feb 18, 2017 2:31 am
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us