Question : T-SQL & Sybase 11.5 ( Incorrect syntax near the keyword 'cursor' )

I have created a stored procedure on a SyBase 11.5 called convert_char2date which the code are describle as below :

CREATE PROCEDURE dbo.convert_char2date
WITH RECOMPILE
AS
    declare @fdate char(10),
                @fdatecancel char(10),
                @ftimecancel char(5)  

    declare cursor1 cursor for
           select FlightDate,DateTime_Cancel,Time_Cancel
           from Passenger_Char
       
        open cursor1
       
        fetch cursor1 into @fdate,@fdatecancel,@ftimecancel
       
        while (@@sqlstatus=0)
           begin
       
           print @fdate
           print @fdatecancel
           print @ftimecancel
       
           fetch cursor1 into @fdate,@fdatecancel,@ftimecancel
           end
       
        close cursor cursor1

RETURN
GO


When I execute this script,I got an error message "Incorrect syntax near the keyword 'cursor'".
I don't know what should I do to correct it. Could you please give me some advice to solve this
error.

Best regards,

  Veasna

Answer : T-SQL & Sybase 11.5 ( Incorrect syntax near the keyword 'cursor' )



The problem is on line 27:


        close cursor cursor1

should be just

       close cursor1


-bret
Random Solutions  
 
programming4us programming4us