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

Dynamic feeding values to ADDRESS DSNREXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Govarthanan

New User


Joined: 22 Nov 2013
Posts: 10
Location: India

PostPosted: Mon Nov 25, 2013 6:10 pm
Reply with quote

Hi All,

This is my first post in the forum. I have a small query with regards to the ADDRESS DSNREXX syntax in REXX.

I have written a REXX prog to get as input a query which in turns fetches the output, but the input queries can have any number of where clauses, which will be replaced by "?"

I know to connect to DB2 and fetch the data, but is it possible to dynamically change the number of values.

For .e.g.

Code:

 ADDRESS DSNREXX                               
    "EXECSQL FETCH C2 INTO :VA1,:VA2,:VA3,:VA4"


The above code will work as expected and fetch values, but if i don know the number of values to be fetched in , i just thought of framing the whole sentence into a variable and substituting it, like below

Code:

FETSTMT = "EXECSQL FETCH C2 INTO :VA1,:VA2,:VA3,:VA4"

ADDRESS DSNREXX FETSTMT

So, I tried this to open clause but the query failed with sqlcode 501, saying the cursor was not at all opened.
1) Is my attempt possible ! meaning can it be dynamically prepared substituted to ADDRESS DSNREXX
2) If it is not possible, is there any other way that i can dynamically do it !

Thanks in advance for your replies icon_smile.gif
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: Mon Nov 25, 2013 10:11 pm
Reply with quote

Hello and welcome to the forum,

Have you Defined and OPENed the cursor?

I do not see this in the code . . .
Back to top
View user's profile Send private message
Govarthanan

New User


Joined: 22 Nov 2013
Posts: 10
Location: India

PostPosted: Mon Nov 25, 2013 11:46 pm
Reply with quote

Dick,
Yes I have the prepare cursor, open cursor too. If it is possible to feed values dynamically to the syntax ADDRESS DSNREXX, I will make the open cursor also to be prepared dynamically in a string and make it work.
Since my doubt was to see if it can be dynamically changed, i just posted one syntax of the code.
Thanks, and let me know if i am not clear.
Back to top
View user's profile Send private message
TheMFKid

New User


Joined: 20 Nov 2013
Posts: 91
Location: India

PostPosted: Tue Nov 26, 2013 10:30 am
Reply with quote

Govarthanan, I ran the below code and it worked as expected. Is this what you are trying to achieve?
Code:
DN= "FETCH C1 INTO :STA.I,:BNB.I,:BATCHD.I,:BATCHT.I,",   
                        ":JOBN.I"                               
ADDRESS DSNREXX "EXECSQL "DN                                     
Back to top
View user's profile Send private message
Govarthanan

New User


Joined: 22 Nov 2013
Posts: 10
Location: India

PostPosted: Tue Nov 26, 2013 11:34 am
Reply with quote

Yes , MFKiddo, Thanks. I tried this syntax and it is working.

Thanks a lot MFKid. icon_biggrin.gif icon_super.gif
Back to top
View user's profile Send private message
TheMFKid

New User


Joined: 20 Nov 2013
Posts: 91
Location: India

PostPosted: Tue Nov 26, 2013 11:54 am
Reply with quote

Superb.. Good to know it helped!

Thanks.
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Routing command Address SDSF to other... TSO/ISPF 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
Search our Forums:

Back to Top