If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > Cannot update cursor but why ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-21-11, 12:23
jll63 jll63 is offline
Registered User
 
Join Date: Mar 2011
Posts: 3
Cannot update cursor but why ?

Hello,

My Sybase is: Sybase IQ/15.1.0.5034

It's my first time using cursors and I'm having trouble. I have reduced it to:

Code:
create table testtable (id integer)
insert into testtable (id) values (1)
insert into testtable (id) values (2)
declare testcur cursor for select * from testtable  for update
open testcur
fetch testcur
update testtable set id = 33 where current of testcur
close testcur
select * from testtable
When I run this, I get a:

Code:
Error: SQL Anywhere Error -633: Update operation attempted on a read-only cursor
SQLState:  42W30
ErrorCode: 7732
I thought I had followed the syntax faithfully so what's happening ?

Thanks,
Jean-Louis
Reply With Quote
  #2 (permalink)  
Old 03-23-11, 11:10
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 443
We have IQ 12.6 and the SQL you attached works perfectly fine for me.
Reply With Quote
  #3 (permalink)  
Old 03-23-11, 11:27
jll63 jll63 is offline
Registered User
 
Join Date: Mar 2011
Posts: 3
Quote:
Originally Posted by trvishi View Post
We have IQ 12.6 and the SQL you attached works perfectly fine for me.
Thanks...

Something seems very wrong with my version (or installation?), I have problems with read-only cursors too, when I mix fetches with updates on another table :-(
Reply With Quote
  #4 (permalink)  
Old 03-23-11, 12:48
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 443
Can you paste the output of

SELECT connection_property ('CHAINED');
Reply With Quote
  #5 (permalink)  
Old 03-24-11, 04:36
jll63 jll63 is offline
Registered User
 
Join Date: Mar 2011
Posts: 3
Quote:
Originally Posted by trvishi View Post
Can you paste the output of

SELECT connection_property ('CHAINED');
It's set to Off. Indeed when I set it to On (SquirrelSQL!Session!Transaction!Toggle Autocommit) my example works.

Thanks for pointing this out :-)

I googled around and found no clear statement that autocommit and updatable cursors don't mix...hmmm...also I thought this would work with Chained=Off:

Code:
begin transaction
declare testcur cursor for select * from testtable  for update
open testcur
fetch testcur
update testtable set id = 33 where current of testcur
fetch testcur
update testtable set id = 33 where current of testcur
close testcur
commit transaction
...but I get the same message:
Code:
Error: SQL Anywhere Error -633: Update operation attempted on a read-only cursor
SQLState:  42W30
ErrorCode: 7732
J-L
Reply With Quote
  #6 (permalink)  
Old 03-24-11, 05:46
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 443
No problem.

By default the chaining is ON when you build IQ atleast on the lower versions I know. So, I guess you need to find out why this was set to off and by who in your team...

And decide accordingly.

Another option is to use begin tran/end tran around the cursor.

Or set chaining on the session level.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On