FOR UPDATE cannot be specified on a READ ONLY cursor

  • Heh, I've searched and searched and searched...

    -- Stephen Cook

  • Sorry, the link wasn't has obvious as I thaught it would be. I can't be certain that this will solve your problem but since the guy hasn't requested more help I can hope it will...

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=5&messageid=229715&P=2#bm230311

  • declare cursor_name cursor

    for select parameter from table_name

    for update

    declare @parameter varchar(35) /* example*/

    declare @counter int

    open cursor_name

    set @counter = 1

    while @counter <= 6 /* how many rows*/

    begin

    fetch next from cursor_name into @parameter

    update table_name set parameter = substring(@parameter,2,3) + substring(@parameter,6,35) where current of cursor_name /* example */

    print @parameter /* show your result */

    set @counter = @counter + 1

    end

    print 'finish'

    close cursor_name

    deallocate cursor_name

  • means that

    no want to read_only or forward_only after declare cursor_name cursor

  • I don't have a READ_ONLY or FORWARD_ONLY in there (the cursor declaration is in the first page of this thread). There is something else going on here.

    I had all but forgotten about this (until I got the email saying the thread was posted to again), apparently nobody cares if this is a slow report. It still bugs me deep down inside but I'm not going to lose sleep over it.

    -- Stephen Cook

  • DECLARE csr CURSOR SCROLL DYNAMIC SCROLL_LOCKS FOR

    SELECT PCPLastName,

    PCPFirstName,

    PCP_MI_Title,

    PAGE

    FROM AuthFormData

    ORDER BY PCPLastName,

    PCPFirstName,

    PCP_MI_Title,

    LastName,

    FirstName,

    MI

    FOR UPDATE OF PAGE

     

    just put specify everything you need. Usually, the defaults are the first option. In this case, [ READ_ONLY | SCROLL_LOCKS | OPTIMISTIC ], READ_ONLY may be the default.


    Ronald San Juan | SQL DBA
    ID 710124 ~ Code "Northwind"

  • I faced the same problem. My table had a single column index (it was the only idx on that table, no primary keys..nothing..). I removed that index and made it a primary key and voila!

    However, my cursor was not even referencing the field in question in the first place. Anyways, it works now so I am happy . Hope this works for you guys as well!

  • Hi,

    I think almost everything can be solved without a cursor, but only for give an answer to your question, try without ORDER BY... that is the reason.

    Regards, an sorry my English...

    Liliana (ARG).

  • Hi

    withought the ORDER BY WORKED FOR ME TOO!!!

    any idea why?

     

    thnaks in advance

    peleg

Viewing 9 posts - 16 through 23 (of 23 total)

You must be logged in to reply to this topic. Login to reply