If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Fetch 'NA' into cursor

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-23-11, 15:04
JSiggi JSiggi is offline
Registered User
 
Join Date: Sep 2011
Posts: 1
Fetch 'NA' into cursor

who now's how I can fetch strings like 'NA' in my cursor. I use dynamic sql in my cobol program.

Declare Cursor .... Select 'NA', Column1, Column2, 1 as testcol, Column3, 'NA'

My fetch into is like this:
fetch into
:hs1
,:Column1
,:Column2
,:hs2
,:Column3
,:hs3

where
hs1 is defined as pic x (02)
hs2 as pic x
hs3 as pic x(02)

When I run the pgm I got the SQLCode -303

Is it possible to fetch this kind of columns ?


Last edited by JSiggi; 09-23-11 at 17:13. Reason: I have resolved the SQLCode -303
Reply With Quote
  #2 (permalink)  
Old 09-23-11, 19:04
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
I see two possible problems with "1 as testcol":
  • 1 is numeric literal since you don't have single quotes around it, so will not go into :hs2 which you have defined as PIC X. You can use '1' or difine the host variable as PIC 9.
  • Get rid of the "as testcol" becasue it is not relevant inside a program. I am not sure if it will cause an error, but is of no use.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On