Yazdığım SP içinde bulunan Cursor Sql server 2005 içinde hata vermezken parametre göndererek çalıştırmak istediğimde çalışmasına rağmen hata veriyor.
'Cursor does not exist' hatası alıyorum. Dışarıdan 3 adet parametre vererek çalıştırmak istediğim spdeki cursor işlemi hata veriyor.
Konu hakkında tavsiyesi olan?
Kod: Tümünü seç
USE [Restoran]
GO
/****** Object: StoredProcedure [dbo].[siparisden_satisa] Script Date: 10/17/2007 22:08:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[siparisden_satisa]
@masa_satis int, @odemesekli varchar(15),@garsonnum smallint
AS
declare @masanum int
declare @kodnumara int
declare @yemekismi varchar(15)
declare @fiyati float
declare @odemem varchar(15)
declare @garsonno smallint
BEGIN
set @masanum=@masa_satis
declare CursorSatir cursor for
select kod,adi,fiyat
from siparis
where masa=@masanum
open cursorSatir
fetch next from CursorSatir into @kodnumara,@yemekismi,@fiyati
while @@fetch_status=0
begin
BEGIN TRANSACTION
insert into satislar(masa,kod,adi,fiyat,odeme,garson) values(@masanum,@kodnumara,@yemekismi,@fiyati,@odemesekli,@garsonnum)
IF @@Error <> 0 -- If there is any error !
BEGIN
ROLLBACK TRANSACTION
END
ELSE
BEGIN
COMMIT TRANSACTION
END
fetch next from CursorSatir into @kodnumara,@yemekismi,@fiyati
end
close cursorsatis
deallocate cursorsatis
delete from siparis
where masa=@masanum
IF @@Error <> 0 -- If there is any error !
RETURN -1
ELSE
RETURN 0
end
Kod: Tümünü seç
exec siparisden_satisa 1,'Nakit',1