View previous topic :: View next topic
|
Author |
Message |
Govarthanan
New User
Joined: 22 Nov 2013 Posts: 10 Location: India
|
|
|
|
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 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
Have you Defined and OPENed the cursor?
I do not see this in the code . . . |
|
Back to top |
|
|
Govarthanan
New User
Joined: 22 Nov 2013 Posts: 10 Location: India
|
|
|
|
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 |
|
|
TheMFKid
New User
Joined: 20 Nov 2013 Posts: 91 Location: India
|
|
|
|
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 |
|
|
Govarthanan
New User
Joined: 22 Nov 2013 Posts: 10 Location: India
|
|
|
|
Yes , MFKiddo, Thanks. I tried this syntax and it is working.
Thanks a lot MFKid. |
|
Back to top |
|
|
TheMFKid
New User
Joined: 20 Nov 2013 Posts: 91 Location: India
|
|
|
|
Superb.. Good to know it helped!
Thanks. |
|
Back to top |
|
|
|