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 JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm
No new posts DD DUMMY & CPU TIME Nileshkul Testing & Performance analysis 16 Mon Dec 19, 2016 11:35 pm
This topic is locked: you cannot edit posts or make replies. Get a job submitted itself every time... arunsoods JCL & VSAM 3 Tue Nov 22, 2016 4:05 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am


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