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
 

 

Declare cursor one time and pass the value using variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
krunalbafna
Warnings : 1

Active User


Joined: 18 Jan 2010
Posts: 143
Location: Pune

PostPosted: Thu Apr 15, 2010 4:53 pm    Post subject: Declare cursor one time and pass the value using variable
Reply with quote

Hi,
I need to define a cursor as follows:
SELECT A.name,A.CDE,A.city FROM table A WHERE A.CDE = CODEX and City IN ( subquery)

Is it possible to declare cursor one time and pass the value using variable in the above query. Ex: In above example CODEX is my variable name. I want to retrieve records depending on values in above varible which keeps on changing in one program and rest query remains same.


Regards,
Krunal
icon_eek.gif
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Apr 15, 2010 5:19 pm    Post subject:
Reply with quote

From what I understand, the cursor for a value of a specific CODEX will return all rows that match. For another value of CODEX, you will need to close the cursor, change the CODEX value and then reopen the cursor.
Back to top
View user's profile Send private message
krunalbafna
Warnings : 1

Active User


Joined: 18 Jan 2010
Posts: 143
Location: Pune

PostPosted: Thu Apr 15, 2010 5:24 pm    Post subject:
Reply with quote

ya i will have to reopen the cursor again..

But is it possible to pass the value using variable from working storage section.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Apr 15, 2010 5:28 pm    Post subject:
Reply with quote

I may be off here, but don't you use a colon to denote a WS variable?
As in
SELECT A.name,A.CDE,A.city FROM table A WHERE A.CDE = :CODEX and City IN ( subquery)
where CODEX is defined in working storage....
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: Thu Apr 15, 2010 9:39 pm    Post subject:
Reply with quote

Hello,

Quote:
But is it possible to pass the value using variable from working storage section.
This is the normal way to provide run-time values to a query. . .

I must be missing something. . . icon_confused.gif
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 Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts DSNACCOX (can it be run on 1 db/ts, t... SRICOBSAS DB2 5 Sat May 06, 2017 12:59 am
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm


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