Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to retrieve resulting row count from an REXX/EXECSQL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: How to retrieve resulting row count from an REXX/EXECSQL
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    Post subject:
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.

http://ibmmainframes.com/viewtopic.php?t=38562&highlight=dsnrexx
http://ibmmainframes.com/viewtopic.php?t=15761&highlight=dsnrexx
http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/DSNAPH10/2.4.6?SHELF=dsnshh10&DT=20010209162045
http://ibmmainframes.com/search.php?mode=results
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Mar 22, 2012 10:36 am    Post subject:
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    Post subject: Reply to: How to retrieve resulting row count from an REXX
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: 642
Location: Whitby, ON, Canada

PostPosted: Thu Mar 22, 2012 5:17 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us