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

Declare cursor one time and pass the value using variable


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 2146
Location: At my coffee table

PostPosted: Thu Apr 15, 2010 5:19 pm
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
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: 2146
Location: At my coffee table

PostPosted: Thu Apr 15, 2010 5:28 pm
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

Moderator Emeritus


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

PostPosted: Thu Apr 15, 2010 9:39 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
No new posts C Compile time time stamps Java & MQSeries 10
No new posts Parallelization in CICS to reduce res... CICS 4
Search our Forums:

Back to Top