Page 1 of 1

Array in SQL Cursor

PostPosted: Tue Aug 30, 2011 3:53 pm
by kakamansai
If we have few values which needs to excluded from the selection and if the values are changing every time, can we use Array name in WHERE cluase of sql, after reading the valuese in to array in COBOL program?

Select * from <table name>
where col1 not in (:ws-array-name)

Throwing the error ws-array-name as UNUSABLE or UNDECLARED HOST VARIABLE

Re: Array in SQL Cursor

PostPosted: Tue Aug 30, 2011 8:21 pm
by GuyC
I think each elementary item is required to have a name.
I haven't compiled it, but something like this :
01  HV-INLIST.                                 
   05  HV-INLIST1              PIC X(3)    VALUE SPACE.
   05  HV-INLIST2              PIC X(3)    VALUE SPACE.
   05  HV-INLIST3              PIC X(3)    VALUE SPACE.
01 HV-TABLE REDEFINES HV-INLIST.
    05  HV-TABLE-ELEMENT OCCURS 3 PIC X(3).


exec sql
   Select * from <table name>
   where col1 not in (:HV-INLIST)
end-exec