fetch multi-row SQL HOST VARIABLE REFENCE INVALID



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

fetch multi-row SQL HOST VARIABLE REFENCE INVALID

Postby tivrfoa » Thu Nov 23, 2017 8:22 pm

Hi,

The code is not compiling for multi-fetch:

S SQL HOST VARIABLE REFERENCE "VAR-NAME" HAD INVALID SYNTAX OR THE      
  REFERENCED HOST VARIABLE WAS AN INVALID SQL VARIABLE TYPE.  THE STATEME
  WAS DISCARDED.        


The column "is not null" (primary key).

01 GD-VAR-NAME                 PIC S9(004) COMP.
                                               
01 TABLE-1.                                    
   02 XXX OCCURS 10 TIMES.                    
      05 VAR-NAME              PIC S9(004) COMP.
     
EXEC SQL                    
  DECLARE C1 CURSOR FOR    
    SELECT VAR_NAME        
    FROM DB2xxx.table-name
    FETCH FIRST 28 ROWS ONLY
END-EXEC.              



This works:
EXEC SQL                                    
  FETCH C1 INTO :GD-VAR-NAME                
END-EXEC    


But this does not compile, giving the error above:
EXEC SQL                        
  FETCH C1 FOR 10 ROWS INTO :XXX
END-EXEC  


Could someone help me, please?
tivrfoa
 
Posts: 84
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 60 times
Been thanked: 0 time

Re: fetch multi-row SQL HOST VARIABLE REFENCE INVALID

Postby tivrfoa » Thu Nov 23, 2017 9:32 pm

The error is: IGYPS0212-S

https://www.ibm.com/support/knowledgece ... 0212S.html

I think the error explanation in the link above is wrong, because the host variable is not VARCHAR. :?
tivrfoa
 
Posts: 84
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 60 times
Been thanked: 0 time

Re: fetch multi-row SQL HOST VARIABLE REFENCE INVALID

Postby tivrfoa » Thu Nov 23, 2017 9:53 pm

So ...

The code I posted was based on the following example:
https://www.ibm.com/support/knowledgece ... fetch1.htm

But it didn't work for me.

So I end up doing like here:
http://ibmmainframes.com/post-282428.html#282428
tivrfoa
 
Posts: 84
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 60 times
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post