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 Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts How to get current date -1 and curren... murali.andaluri DFSORT/ICETOOL 3 Wed Mar 08, 2017 2:09 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm


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