|
Posted by £ukasz W. on 10/05/06 19:43
Hello everybody!
I have a small table "ABC" like this:
id_position | value
---------------------------
1 | 11
2 | 22
3 | 33
I try to use a dynamic cursor as below.
When the statement "order by id_position" in declare part of the cursor_abc
is omitted - cursor work as it should.
But when the statement "order by id_position" is used, cursor behave as
static one.
What's the matter, does anybody know?
Code:
declare @id_position as int, @value as int
DECLARE cursor_abc CURSOR
FOR
select id_position, value from abc
order by id_position
set nocount on
open cursor_abc
FETCH NEXT FROM cursor_abc
INTO @id_position, @value
WHILE @@FETCH_STATUS = 0
BEGIN
print @id_position
print @value
print '----------------------------'
update abc set value=666 --next reading should give value=666
FETCH NEXT FROM cursor_abc
INTO @id_position, @value
END
CLOSE cursor_abc
DEALLOCATE cursor_abc
GO
Regards
Lucas
Navigation:
[Reply to this message]
|