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 

Positioned Update

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Wed Dec 08, 2004 4:22 pm    Post subject: Positioned Update Reply with quote

I have the following codes:
Code:

DECLARE CURA CURSOR FOR
     SELECT COLA, COLB, COLC
     FROM TBALEA
     FOR UPDATE OF COLB, COLC
.......
.......
UPDATE TABLEA SET COLB = :VALB, COLC = :VALC
    WHERE CURRENT OF CURA

This works fine. But if I add "ORDDER BY COLA" clause to the declared cursor, the update will fail with a sqlcode of -510, ERROR: THE TABLE DESIGNATED BY THE CURSOR OF THE UPDATE OR DELETE STATEMENT CANNOT BE MODIFIED. There is no mention of positioned update doesn't support "ORDER BY" in the manual. Any explanation?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Dec 09, 2004 6:31 am    Post subject: Reply with quote

Danm,

When you use an ORDER BY clause on a cursor, then it becomes a Read-only cursor which CANNOT BE used to update or delete the underlying rows of the result table. However you can have a ORDER BY clause when you have declared the cursor as SENSITIVE STATIC scrollable which can be used to update.

Quote:

There is no mention of positioned update doesn't support "ORDER BY" in the manual. Any explanation?


Well there is , Check this link for a detailed explanation of it.(scroll down to the bottom where for Read-only cursors)

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/5.40?DT=20010718164132

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Thu Dec 09, 2004 10:42 am    Post subject: Reply with quote

Kolusu,

Thanks for the quick response.
Back to top
View user's profile Send private message
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Fri Jan 28, 2005 1:15 pm    Post subject: Reply with quote

Kolusu,

I got a sqlcode of -104 from "DECLARE C1 SENSITIVE STATIC SCROLL...." in DSNREXX:

Sqlcode : -104,
Sqlstate: 42601,
Sqlerrp: DSNTZDCL,
Sqlerrmc: SENSITIVE:CURSOR

I checked the SQL Reference, looks like the syntax is correct. Any suggestion?

Code:

SelData = "SELECT SS#, CITY, STATE",
  "FROM" DB_Table,
  "ORDER BY SS#",
  "FOR UPDATE OF CITY, STATE"
"EXECSQL DECLARE C1 SENSITIVE STATIC SCROLL CURSOR FOR S1" 
"EXECSQL PREPARE S1 FROM :SELDATA"
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jan 28, 2005 1:58 pm    Post subject: Reply with quote

Danm,
You need to prepare the statement and use it in the declaration.
ex:
Code:
 
"EXECSQL PREPARE S1 FROM :SELDATA"
"EXECSQL DECLARE C1 SENSITIVE STATIC SCROLL CURSOR FOR S1"
"EXECSQL OPEN C1"


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Mon Feb 07, 2005 10:35 am    Post subject: Reply with quote

Kolusu,

I am still getting the -104 sqlcode. Any one of the keywords (SENSITIVE, STATIC or SCROLL) will cause the -104. I am running DB2 V7.2. Any suggestion?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Feb 08, 2005 8:48 am    Post subject: Reply with quote

Danm,

Make sure that you don't have any junk characters in columns 73 thru 80 in your sql.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Tue Feb 08, 2005 12:54 pm    Post subject: Reply with quote

Kolusu,

No, I don't have any character in columns 73 thru 80. I placed several "say" statements in the REXX EXEC to check for the correct SQL statements. If I removed the "ORDER BY" clause from SelData and "SENSITIVE STATIC SCROLL" from the DECLARE, then it works fine.
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 -> Database All times are GMT - 5 Hours
Page 1 of 1

 
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