locked
Stored Procedure Cursor problem RRS feed

  • Question

  • User809322603 posted

    hi friends

    Please check the error in my stored procedure

    create procedure payments
    as
    declare @mplan varchar(800),@id int

    DECLARE myqry CURSOR FOR
    select manuid,memberPlan from manubill
    OPEN myqry
    FETCH  myqry into @id,@mplan

    if (@id =1)
    begin
     update manubill set status ='Deactive'
    end
    close myqry



    exec payments

    this is giving following error

    Msg 16915, Level 16, State 1, Procedure payments, Line 6
    A cursor with the name 'myqry' already exists.

    Please see the table coding

    create table manubill(billid int identity(1,1), manuid int ,memberPlan  varchar(8000), startdate datetime, enddate datetime, plancost float, status varchar(8000)  )

    insert into manubill(manuid,memberPlan,startdate,enddate,plancost,status) values(1,'p2','2012-01-26', '2012-02-25', 550,'Active')
    insert into manubill(manuid,memberPlan,startdate,enddate,plancost,status) values(1,'p4','2012-02-26', '2012-03-25', 650,'Active')



    Friday, December 30, 2011 4:19 AM

Answers

All replies