Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2011

    Unanswered: 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 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 18:13. Reason: I have resolved the SQLCode -303

  2. #2
    Join Date
    May 2003
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts