View previous topic :: View next topic
|
Author |
Message |
rohit2219
New User
Joined: 10 Feb 2009 Posts: 7 Location: India
|
|
|
|
hi
I have a query which is held in a stem variable in parts as given below
ARR.1=UPDATE CLIENT_TAB
ARR.2=SET EMP_NO='22222'
ARR.3=WHERE EMP_NO='11111'
im not able to execute this query held in stem vars through REXX
there are syntaxes in IBM manual for executing statements in a single variable like given below
statement = "UPDATE STAFF SET JOB = 'Clerk' WHERE JOB = 'Mgr'"
CALL SQLEXEC 'EXECUTE IMMEDIATE :statement'
IF ( SQLCA.SQLCODE < 0) THEN
SAY 'Update Error: SQLCODE = ' SQLCA.SQLCODE
But Im not able to execute the above syntax for query held in a stem
I tried to do use the below syntax too
CALL SQLEXEC ':ARR.1 :ARR.2 :ARR.3 :ARR.4"
but still it give syntax error
Concateneting the stem variable into a single variable and executing it wont serve my purpose
is there any way to execute a query held in stem varable or in multiple variables?? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
Concateneting the stem variable into a single variable and executing it wont serve my purpose
|
why not ? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Quote: |
there are syntaxes in IBM manual for executing statements in a single variable like given below |
Perhaps that is the method that will work.
Quote: |
Concateneting the stem variable into a single variable and executing it wont serve my purpose |
Would you care to elaborate on the reasoning behind this statement. |
|
Back to top |
|
|
rohit2219
New User
Joined: 10 Feb 2009 Posts: 7 Location: India
|
|
|
|
this is because my query is not so small as given below..it may extend to more than 500 letters of code
It can be an insert query which can amount to more than more than 1000 letters and if Im correct a rexx variable can only hold 255 letters (im not sure on this).
Is there any upper limit regarding the letters or bytes which a variable can hold?
If no, then Concateneting the stem variable into a single variable and executing it maybe a temporary solution to my problem |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Then I suggest that you try that method and report back with the results. |
|
Back to top |
|
|
rohit2219
New User
Joined: 10 Feb 2009 Posts: 7 Location: India
|
|
|
|
as of now I maybe able to execute it as given below
statement=ARR.1 || ARR.2| | ARR.3
CALL SQLEXEC 'EXECUTE IMMEDIATE :statement'
IF ( SQLCA.SQLCODE < 0) THEN
SAY 'Update Error: SQLCODE = ' SQLCA.SQLCODE
But what possible problems can arise if the array is bigger?? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
If you think about it, you are concatenating the stem variables into one string anyway.
Have you considered writing all of the statements to a FB 80 dataset and then using that as a SYSIN for your query ? |
|
Back to top |
|
|
rohit2219
New User
Joined: 10 Feb 2009 Posts: 7 Location: India
|
|
|
|
Hi expat
Im executing the DB2 statements in rexx using DSNREXX..
How can I execute the query after writing it into a dataset? are you suggesting to use a job to execute this query?thats also one possible solution...
i will try the other method and post the results anyways? But will concatenation help in executing a big query? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
Is there any upper limit regarding the letters or bytes which a variable can hold? |
why don' t You test it Yourself
Code: |
/* rexx */
Trace "O"
string = ""
do forever
say right(length(string),8)
string = string || copies(" ",1024)
end
exit
|
|
|
Back to top |
|
|
rohit2219
New User
Joined: 10 Feb 2009 Posts: 7 Location: India
|
|
|
|
Hi
thanks for the suggestions I will test these and get back with results |
|
Back to top |
|
|
rohit2219
New User
Joined: 10 Feb 2009 Posts: 7 Location: India
|
|
|
|
hi
as of now concatenating the stem variables into a single variable seems to work...i concatenated and executed queries with some 200-300 line length..seems to be fine.....hope no probs arise in the long run |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Thanks for letting us know it is working
You might consider checking the lengths and have a controlled termination rather than a surprise abend. . . |
|
Back to top |
|
|
|