IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need More Clarification on 'IN'


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Thu Apr 22, 2010 2:20 pm
Reply with quote

Need Clarification on 'IN'
Hi Dick Brenholtz,

I used host variable-array in the below SQL statements, but i got compilation error as 'UNUSABLE HOST VARIABLE'. <my DB2 version is 9.5>, Is host variable array is applicable only for multi-row fetch and insert then i tried for select,

EXEC SQL
DECLARE CSR1 CURSOR
SELECT C1 FROM TAB1
WHERE C2 IN(:WS-VAR-GRP)
END-EXEC

Declaration for WS-VAR-GRP
01 WS-VAR-GRP.
03 WS-VAR-ARR OCCURS 20 TIMES.
05 WS-VAR PIC S9(9) COMP.

in my previous posting i didn't get the compilation when i declared as,

Declaration for WS-VAR-GRP
01 WS-VAR-GRP.
05 WS-VAR1 PIC S9(9) COMP.
05 WS-VAR2 PIC S9(9) COMP.
.
.
.
05 WS-VAR20 PIC S9(9) COMP.

Is any slack variable(assumption) or any other stuff which prevents to operate on host variable array?

Please clarify.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Apr 22, 2010 4:56 pm
Reply with quote

DB2 can interpret things like
Code:

01 WS-VAR-GRP.
    05 filler  PIC S9(9) COMP.
    05 filler  PIC S9(9) COMP.
    05 filler  PIC S9(9) COMP.


but does not like it when you use the OCCURS clause.

so, if you need a cobol internal table
have the table redefine the group item
Code:

01 WS-VAR-GRP.
    05 filler  PIC S9(9) COMP.
    05 filler  PIC S9(9) COMP.
...
    05 filler  PIC S9(9) COMP.

01 ws-var-tab.
    05  ws-var-item occurs 20 times.
         10  ws-var-element PIC s9(9) comp.



the other thread mentioned this -
you can not use a host variable array in an IN clause
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Need clarification of VSAM FCT and DF... CICS 15
No new posts Clarification regarding BUFNI & B... JCL & VSAM 14
No new posts DB2 9 - Utilities - COPY,REORG Clarif... DB2 3
No new posts Clarification on INDEX & SET stat... COBOL Programming 2
No new posts Evaluate statement - clarification COBOL Programming 2
Search our Forums:

Back to Top