I'm having a bit of a problem using a dynamic cursor where I update the underlying data but the cursor does not show the update on the second fetch. Although books can be incorrect the following sysntax is just as it is shown in the book I have:
If original value of flag is 'A'
Declare @date smalldatetime
Declare @flag varchar(100)
DECLARE @test varchar(100)
DECLARE ItemCursor CURSOR GLOBAL SCROLL DYNAMIC FOR
SELECT date,flag FROM itemtemp ORDER BY Item,Date
OPEN ItemCursor
FETCH LAST FROM ItemCursor INTO @date,@flag
PRINT 'Date = ' + CONVERT(varchar(100),@date)
PRINT 'Oos_flag = ' + CONVERT(varchar(100),@flag)
UPDATE itemtemp set flag = 'X' Where date = '9/24/2002'
FETCH LAST FROM ItemCursor INTO @date,@flag
PRINT 'Date = ' + CONVERT(varchar(100),@date)
PRINT 'Oos_flag = ' + CONVERT(varchar(100),@oos_flag)
This code works if I close and re-open the cursor before the second fetch but the book I have does not show this. It is my understanding that the cursor will be rebuilt on each fetch. I'm baffled any help would be appreciated...
If original value of flag is 'A'
Declare @date smalldatetime
Declare @flag varchar(100)
DECLARE @test varchar(100)
DECLARE ItemCursor CURSOR GLOBAL SCROLL DYNAMIC FOR
SELECT date,flag FROM itemtemp ORDER BY Item,Date
OPEN ItemCursor
FETCH LAST FROM ItemCursor INTO @date,@flag
PRINT 'Date = ' + CONVERT(varchar(100),@date)
PRINT 'Oos_flag = ' + CONVERT(varchar(100),@flag)
UPDATE itemtemp set flag = 'X' Where date = '9/24/2002'
FETCH LAST FROM ItemCursor INTO @date,@flag
PRINT 'Date = ' + CONVERT(varchar(100),@date)
PRINT 'Oos_flag = ' + CONVERT(varchar(100),@oos_flag)
This code works if I close and re-open the cursor before the second fetch but the book I have does not show this. It is my understanding that the cursor will be rebuilt on each fetch. I'm baffled any help would be appreciated...