Topic
  • 2 replies
  • Latest Post - ‏2012-10-09T14:17:43Z by SystemAdmin
SystemAdmin
SystemAdmin
3105 Posts

Pinned topic Multi row fetch and VARCHAR

‏2012-10-09T12:12:05Z |
Hi all,

lately I tried to fetch a VARCHAR with a multi row fetch. Unfortunately I didn't managed to do it correctly. Can you help me?

This is the definition of my field (taken from DCLGEN):

03 MY-TEXT. 49 MY-TEXT-LEN    PIC S9(4) USAGE COMP. 49 MY-TEXT-TEXT   PIC X(1000).


I changed it that way:

03 MY-TEXT           OCCURS 100. 49 MY-TEXT-LEN    PIC S9(4) USAGE COMP. 49 MY-TEXT-TEXT   PIC X(1000).


My multi row fetch looks like this:

EXEC SQL FETCH NEXT ROWSET FROM CMYTEXT FOR 100 ROWS INTO :MY-TEXT END-EXEC


And last but not least, I get the following error from the compiler:

HOST VARIABLE ARRAY 
'MY-TEXT' IS EITHER NOT DEFINED OR IS NOT USABLE


What is wrong with my definition for the multi row fetch?
Does somebody see it on the first glance?
Updated on 2012-10-09T14:17:43Z at 2012-10-09T14:17:43Z by SystemAdmin
  • kwcaldw
    kwcaldw
    8 Posts

    Re: Multi row fetch and VARCHAR

    ‏2012-10-09T13:13:03Z  
    Add SYNC to your length field:

    49 MY-TEXT-LEN PIC S9(4) USAGE COMP SYNC.
  • SystemAdmin
    SystemAdmin
    3105 Posts

    Re: Multi row fetch and VARCHAR

    ‏2012-10-09T14:17:43Z  
    • kwcaldw
    • ‏2012-10-09T13:13:03Z
    Add SYNC to your length field:

    49 MY-TEXT-LEN PIC S9(4) USAGE COMP SYNC.
    Fantastic. That answered my question.

    I had to add the SYNC keyword at the end.

    Many thanks.