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

is it possible to pass occurs elements in select cursor?


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

New User


Joined: 01 Mar 2005
Posts: 20

PostPosted: Sun Oct 26, 2008 9:06 pm
Reply with quote

Hi,
I have a requirement to pass table elements(occurs elements) to SELECT query (through CURSOR) in cobol-db2 program like below

SELECT col1
col2
FROM table1
WHERE col3 = :col3-table1-var
AND col4_da >= :ws-beg-da
AND col4_da < :ws-end-da
AND col5 IN (:ws-itemtype(1),
:ws-itemtype(2),
...etc.
:ws-itemtype(10))


Does Passing occurs elements to a embedded query will work? If not,
could you please suggest me the alternative solution to achieve the same requiremnt?

Thanks alot for all ur support
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Oct 27, 2008 1:25 am
Reply with quote

Hello,

Did you try this?

If so, what happened?

If not, try and post back if you have any questions.

For questions like this, you will be far more productive running a simple test - someone will be here if there are questions or problems.
Back to top
View user's profile Send private message
i_suman

New User


Joined: 01 Mar 2005
Posts: 20

PostPosted: Tue Nov 04, 2008 4:39 am
Reply with quote

Hi,

I am getting the following compilation error when tried as below.

IGYDS0226-E DSNH104I DSNHPARS ILLEGAL SYMBOL "(". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: + -

DECLARE FS_RVW_10174_CSR CURSOR
WITH HOLD FOR
SELECT CRE_TS
,REVW_ITEM_TY_CD
FROM AAA_FS_RVW_10174
WHERE IR_NO = 0
AND CRE_DA >= '2003-11-14'
AND CRE_DA < '2008-12-31'
AND REVW_ITEM_TYPE_CD IN
(:WS-REVW-ITEM-TY-CD(1),
:WS-REVW-ITEM-TY-CD(2),
:WS-REVW-ITEM-TY-CD(3),
:WS-REVW-ITEM-TY-CD(4),
:WS-REVW-ITEM-TY-CD(5),
:WS-REVW-ITEM-TY-CD(6),
:WS-REVW-ITEM-TY-CD(7),
:WS-REVW-ITEM-TY-CD(8),
:WS-REVW-ITEM-TY-CD(9),
:WS-REVW-ITEM-TY-CD(10))

FOR READ ONLY
END-EXEC.

As per my understanding I think we can't pass index / subscript variable to the query in DECLARE CURSOR clause. [I tried even giving variable name instead of numbers in ws-revw-item-ty-cd( ).]

So I went with some alternative way. If some one got the solution to this please let us know.

Thanks.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Nov 04, 2008 10:35 pm
Reply with quote

01 FILLER REDEFINES WS-SEARCH.
05 WS-REVW-ITEM-TY-CD OCCURS 100 TIMES.
10 WS-REV PIC X(10)

01 WS-SEARCH.
05 WS-SEARCH1 PIC X(10).
05 WS-SEARCH2 PIC X(10).
.......
......


USE WS-SEARCH1,2,3,4 IN YOUR 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 How to pass the PARM value to my targ... COBOL Programming 8
No new posts Dynamically pass table name to a sele... DB2 2
No new posts SELECT from data change table DB2 5
No new posts Select two different counts from SQL... DB2 6
No new posts Select a DB2 value in a specific deci... DB2 4
Search our Forums:

Back to Top