Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

is it possible to pass occurs elements in select cursor?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: is it possible to pass occurs elements in select cursor?
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

Site Director


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

PostPosted: Mon Oct 27, 2008 1:25 am    Post subject:
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    Post subject: Reply to: is it possible to pass occurs elements in select c
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Group elements using ICETOOL Learncoholic DFSORT/ICETOOL 2 Fri Apr 14, 2017 11:01 am
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us