View previous topic :: View next topic
|
Author |
Message |
Per Morsing
New User
Joined: 21 Mar 2012 Posts: 2 Location: dk
|
|
|
|
Hi
How do i write correct Rexx/Execsql to retrieve resulting rowcount :
I've tried this but is does NOT work ?
Code: |
/* REXX */
TRACE R
DB2ID = 'GIDI'
zcnt=0
'SUBCOM DSNREXX'
IF RC THEN
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX
'CONNECT' db2id
SQLSTMT = "SELECT COUNT(*)",
"FROM AAMB.AAMB1T05CUST A,",
" AAMB.AAMB1T07CPRG B"
"WHERE A.CSTPGRCD = B.CSTPGRCD",
" AND A.CSTPGRCD = 'C0'"
"EXECSQL DECLARE C1 CURSOR FOR S1"
"EXECSQL PREPARE S1 FROM :SQLSTMT"
"EXECSQL OPEN C1"
"execsql fetch c1 into :Zcnt"
Say z |
thanks :-) |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
Quote: |
I've tried this but is does NOT work |
?Probably the biggest waste of time on the forum
When something "does not work" you need to post what happened. Some error? An abend? Unexpected/undesired results? Did you run a trace?
Some kind people will try to help you anyaway, but many of us want to see what you are actually dealing with. |
|
Back to top |
|
|
Per Morsing
New User
Joined: 21 Mar 2012 Posts: 2 Location: dk
|
|
|
|
Hi Dick
Ok sorry, what i meant was that my little example of a query should return in a variabel somewhere , the number of Rows which will be returned by the Select stmt .. I'm not quite sure whether it can be done at all..
I thought that the select count(*) would return the number of rows
returned in the variabel Zcnt .. specified in stmt:
execsql fetch c1 into :Zcnt ...
ive also tried to obtain it from another varaiable : sqlca.rowcount
but neither works ..
My intention was to use the number of rows retuned in some
rexx DO stmts later on ...
bregards and thanks for your attention on this matter :-) |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
There is nothing wrong with your concept; it will work once you have corrected the syntax issues.
Hint: there is a missing comma in your SQLSTMT assignment statement. |
|
Back to top |
|
|
|