Hi,
I'm getting a new problem with cursors in triggers.
I would like to replace all my cursor fetching in all triggers but i did'nt know which is the best pratice.
Here is a sample of my trigger code :
Is there a way to don't use cursors ?
Thanks in advance.
I'm getting a new problem with cursors in triggers.
I would like to replace all my cursor fetching in all triggers but i did'nt know which is the best pratice.
Here is a sample of my trigger code :
Code:
ALTER TRIGGER [dbo].[tia_tarif_vente] ON [dbo].[tarif_vente] FOR insert AS declare @tarif_vente_numart integer declare @tarif_vente_codtar varchar(10) declare @tarif_vente_datdebval datetime declare @curs_new_datfinval datetime declare @curs_new_prixventedefinitif numeric(15,3) DECLARE curs_tia_tarif_vente CURSOR LOCAL FOR select i.numart,i.codtar,i.datdebval,i.datfinval,i.prixventedefinitif from inserted i OPEN curs_tia_tarif_vente FETCH curs_tia_tarif_vente INTO @tarif_vente_numart,@tarif_vente_codtar,@tarif_vente_datdebval,@curs_new_datfinval,@curs_new_prixventedefinitif WHILE @@Fetch_Status = 0 BEGIN if @tarif_vente_codtar = 'G' exec dbo.tg_tarif_vente_tib @tarif_vente_codtar,@tarif_vente_numart,@curs_new_datfinval,@curs_new_prixventedefinitif FETCH curs_tia_tarif_vente INTO @tarif_vente_numart,@tarif_vente_codtar,@tarif_vente_datdebval,@curs_new_datfinval,@curs_new_prixventedefinitif END CLOSE curs_tia_tarif_vente DEALLOCATE curs_tia_tarif_vente return
Thanks in advance.
Comment