MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

REXX for MULTI ROW FETCH
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
Pknair
Beginner


Joined: 29 Nov 2005
Posts: 26
Topics: 9

PostPosted: Fri Oct 19, 2007 9:21 am    Post subject: REXX for MULTI ROW FETCH Reply with quote

Anyone has an idea of how to do a mutli row fetch using REXX. I'm able to declare a cursor. But the fetch statement always gives me a -104.

SQLSTMT='SELECT CREATOR , NAME FROM SYSIBM.SYSTABLES WHERE CREATOR = 'XXXXX'"

SQLATTR = " WITH ROWSET POSITIONING"

ADDRESS DSNREXX "EXECSQL DECLARE C1 CURSOR FOR S1"

ADDRESS DSNREXX "EXECSQL PREPARE S1 INTO :OUTSQLDA ATTRIBUTES :SQLATTR FROM :SQLSTMT"

ADDRESS DSNREXX "EXECSQL OPEN C1"

ADDRESS DSNREXX "EXECSQL FETCH NEXT ROWSET FROM C1 FOR 100 ROWS USING DESCRIPTOR :OUTSQLDA"

The above fetch always gives me -104.

Thanks in advance
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Fri Oct 19, 2007 10:34 am    Post subject: Reply with quote

Is that the exact code? Why is there a single quote at the beginning of the SQLSTMT assignment and a double quote at the end?
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Fri Oct 19, 2007 2:08 pm    Post subject: Reply with quote

Which statement is giving the problem?
My FETCH statement looks like this:
Code:

'EXECSQL FETCH C1 INTO :r_nsc, :r_account, :r_limitamt, :r_priority'

or
Code:

'EXECSQL FETCH C1 USING DESCRIPTOR :outsqlda'

followed by:
Code:

Do while sqlcode = 0
   :
   :
   /* do next fetch here */
End


and it works just fine
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
Pknair
Beginner


Joined: 29 Nov 2005
Posts: 26
Topics: 9

PostPosted: Mon Oct 22, 2007 9:06 am    Post subject: Reply with quote

Hi JSharon
That was a typo. the SQLSTMT statement did not have a singl quote.

Hi Nic
The Fetch that you are executing retireves one row at a time. Whereas the one that I am trying to execute retrieves multiple rows. It uses the ROWSET keyword in the fetch and the DECLARE cursor.
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Mon Oct 22, 2007 2:04 pm    Post subject: Reply with quote

I have not seen the ROWSET keyword in relation to Rexx but then I am only up to Version 7. If you are sure you can use ROWSET in a Rexx program then I would double-check the syntax with the manual. Unfortunately I do not have a V8 or a messages manual on me so I cannot help further at this stage.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Mon Oct 22, 2007 3:19 pm    Post subject: Reply with quote

Looking at the syntax in the manual, it looks like the FETCH syntax should be INTO DESCRIPTOR, not USING DESCRIPTOR.
Back to top
View user's profile Send private message
Pknair
Beginner


Joined: 29 Nov 2005
Posts: 26
Topics: 9

PostPosted: Thu Oct 25, 2007 10:30 am    Post subject: Reply with quote

I tried using the "INTO" keyword but the result is still the same. I'm getting SQLCODE of -104 when trying to execute the FETCH. All the other SQLs gave me an SQLCODE of "0".
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Thu Oct 25, 2007 11:32 am    Post subject: Reply with quote

2 things. First, I didn't read far enough down in the FETCH documentation. Missed this:
Code:

Alternative syntax and synonyms: USING DESCRIPTOR can be specified as a synonym for INTO DESCRIPTOR.
dang.

Second (please don't be offended), what version of DB2 are you running? The multiple row fetch is not available until v8. As far as I can tell, the FETCH syntax looks fine. Post the full text of the -104. That might provide some insight.
Back to top
View user's profile Send private message
Pknair
Beginner


Joined: 29 Nov 2005
Posts: 26
Topics: 9

PostPosted: Thu Oct 25, 2007 1:49 pm    Post subject: Reply with quote

I'm sorry if I have in any of my previous replies , unintentionally offended you. Infact I do appreciate all the help being extended by everyone.

The version of DB2 is 8 The error is as given below

SQLCODE =-104
SQLERRMC =ROWSET C1, C2, ... C200
SQLERRP =DSNTZFET
SQLERRD =0,0,0,0,0,0
SQLWARN = , , , , , , , , , ,
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Thu Oct 25, 2007 1:59 pm    Post subject: Reply with quote

No offense at all. Some people are a little over-sensitive when you ask a question about versions if they're using a feature only available in a newer version.

I'm at a loss here. It almost looks like DB2 does not like the ROWSET keyword. Just for grins, would you be willing to change this to a singular FETCH just to see if that works? At least we'd be able to narrow down the problem to the multiple row fetching functionality.
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Thu Oct 25, 2007 2:16 pm    Post subject: Reply with quote

I just had a horrible little thought - is it possible that the version of DSNREXX you are you using is at the right level for DB2 V8? You would probably have to have your sysprogs or DBAs check that info. I do not know if an incompatible version would cause that error - possiby not but if all else fails...
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
Pknair
Beginner


Joined: 29 Nov 2005
Posts: 26
Topics: 9

PostPosted: Thu Oct 25, 2007 2:18 pm    Post subject: Reply with quote

I'm not sure about the DSNREXX version, However As for JSHARON's question I did try with the singleton select and it does work fine
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Thu Oct 25, 2007 2:22 pm    Post subject: Reply with quote

Something else you might try is to put this functionality into a COBOL pgm as static SQL to see if that works.
Back to top
View user's profile Send private message
Pknair
Beginner


Joined: 29 Nov 2005
Posts: 26
Topics: 9

PostPosted: Thu Oct 25, 2007 2:28 pm    Post subject: Reply with quote

The cobol program works fine too.

Does anyone know the different statements that can be passed in the ATTRIBUTES
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Thu Oct 25, 2007 3:41 pm    Post subject: Reply with quote

The ATTRIBUTES syntax in the PREPARE looks fine. I can only suggest two more things. First, try to code the WITH ROWSET POSITIONING directly in the DECLARE cursor, and second, try a cursor name in the C51-C100 range. If neither of those works, you might have the nightmare that Nic Clouston presented.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group