Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Cursors based on temporary tables

Author  Topic 

tintin31
Starting Member

14 Posts

Posted - 2001-03-01 : 15:54:51
Can any one tell me why this is not working. Can I only update a cursor that is based on a non-temporary table:

quote:

DECLARE @iTest_Id int
DECLARE @sFname varchar(10)

CREATE TABLE #test (
test_id int not null
, fname varchar(10) not null )

INSERT INTO #test values ( 1, 'Bob' )
INSERT INTO #test values ( 2, 'Sue' )
INSERT INTO #test values ( 3, 'Martha' )

DECLARE curTest CURSOR
LOCAL DYNAMIC
FOR SELECT test_id, fname
FROM #test
ORDER BY test_id
FOR UPDATE OF fname

OPEN curTest

FETCH FIRST FROM curTest
INTO @iTest_Id, @sFname

WHILE @@Fetch_Status = 0
BEGIN
UPDATE #test
SET fname = 'DELETE'
WHERE CURRENT OF curTest

FETCH NEXT FROM curTest
INTO @iTest_Id , @sFname
END

CLOSE curTest
DEALLOCATE curTest



I am getting the following message:

Server: Msg 16929, Level 16, State 4, Line 14
The cursor is READ ONLY.



Edited by - tintin31 on 03/01/2001 16:02:31
   

- Advertisement -