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

How to retrieve resulting row count from an REXX/EXECSQL


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Per Morsing

New User


Joined: 21 Mar 2012
Posts: 2
Location: dk

PostPosted: Wed Mar 21, 2012 6:41 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Mar 21, 2012 6:48 pm
Reply with quote

the following links may help.
by the way, does not appear that your syntx is correct:
ADDRESS DSNREXX
'CONNECT' db2id

but then you would never know, since you never check the RC.

ibmmainframes.com/viewtopic.php?t=38562&highlight=dsnrexx
ibmmainframes.com/viewtopic.php?t=15761&highlight=dsnrexx
publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/DSNAPH10/2.4.6?SHELF=dsnshh10&DT=20010209162045
ibmmainframes.com/search.php?mode=results
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: Thu Mar 22, 2012 10:36 am
Reply with quote

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 icon_sad.gif

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
View user's profile Send private message
Per Morsing

New User


Joined: 21 Mar 2012
Posts: 2
Location: dk

PostPosted: Thu Mar 22, 2012 3:19 pm
Reply with quote

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
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Thu Mar 22, 2012 5:17 pm
Reply with quote

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
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 -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts To get the count of rows for every 1 ... DB2 3
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
Search our Forums:

Back to Top