BUG: Error 16929, "Cursor Is Read Only" for Cursor w/OpenQuery()ID: Q197392
|
Updating a remote table using the UPDATE WHERE CURRENT OF statement on a
cursor opened with the OpenQuery() syntax fails with the following error
message:
Msg 16929, Level 16, State 1
The cursor is READ ONLY.
A static cursor is being generated with the OpenQuery() syntax.
To work around this problem, do either of the following:
declare @i int
declare curs1 cursor for
select a from OpenQuery(server1, 'select a from pubs.dbo.ab')
open curs1
fetch curs1 into @i
while @@fetch_status <> -1
begin
update openquery(server1, 'select a, b from pubs.dbo.ab')
set b = 'XXX' where a = @i
fetch curs1 into @i
end
close curs1
deallocate curs1
go
Where column 'a' is the primary key for table 'ab' on the linked server
'server1'. Column 'b' may be any other column in the table.
Microsoft has confirmed this to be a problem in SQL Server version 7.0.
Dynamic, Forward-Only and Fast Forward-Only cursors are not supported over
distributed queries. If you request any of the above types of cursors, the
cursor will attempt to open a keyset cursor by default. If a keyset cursor
is not supported for the query, a static cursor will be generated. This is
expected behavior.
However, if a keyset cursor is opened using the OpenQuery() syntax, it will
incorrectly be downgraded to a static cursor. The end result is, no matter
what type of cursor is requested with the OpenQuery() syntax, a static
cursor is generated. Because static cursors are Read Only, any attempt to
update the cursor will receive the error message noted in the SYMPTOMS
section of this article.
For more information on cursors, see the "Declare Cursor (T-SQL) topic in
the SQL Server 7.0 Books Online.
Additional query words: insensitive err oledb
Keywords : SSrvTran_SQL kbbug7.00
Version : WINNT:7.0
Platform : winnt
Issue type : kbbug
Last Reviewed: April 20, 1999