View previous topic :: View next topic |
Author |
Message |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Wed Dec 08, 2004 4:22 pm Post subject: Positioned Update |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Dec 09, 2004 6:31 am Post subject: |
|
|
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 |
|
 |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Thu Dec 09, 2004 10:42 am Post subject: |
|
|
Kolusu,
Thanks for the quick response. |
|
Back to top |
|
 |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Fri Jan 28, 2005 1:15 pm Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Jan 28, 2005 1:58 pm Post subject: |
|
|
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 |
|
 |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Mon Feb 07, 2005 10:35 am Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Feb 08, 2005 8:48 am Post subject: |
|
|
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 |
|
 |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Tue Feb 08, 2005 12:54 pm Post subject: |
|
|
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 |
|
 |
|
|