Results 1 to 2 of 2

Thread: Cursor do not work

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Unhappy

    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.

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    interesting....I use this code with the Northwind DB in SQL 7 and it works fine:

    Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width