PDA

Click to See Complete Forum and Search --> : Cursor do not work


mutley
Jun 7th, 2000, 01:18 AM
Hi


I have a Stored Procedure with Cursor, I open the cursor out while as:

open cr_Agenda
fetch next from cr_Agenda into @Whr_ini, @Whr_fim,@wlocal,@wnom_loc,@Wccu

while (@@FETCH_STATUS = 0)
begin
<statements>
fetch next from cr_Agenda into @Whr_ini, @Whr_fim,@wlocal,@wnom_loc,@wccu
end
When it read the last row +1 , Where Is wrong ?

Server: Msg 16915, Level 16, State 1, Line -1074292529
A cursor with the name 'cr_Agenda' already exists.

Clunietp
Jun 7th, 2000, 09:41 AM
interesting....I use this code with the Northwind DB in SQL 7 and it works fine:


CREATE PROCEDURE spu_test AS

declare @MyCustomerID varchar(50)

Declare MyCursor cursor for
select CustomerID from Customers

open MyCursor

fetch next from MyCursor into @MyCustomerID

while (@@FETCH_STATUS = 0)
begin
print @MyCustomerID
fetch next from MyCursor into @MyCustomerID
end