March 25, 2002 at 6:00 am
Hi all ,
I have the following problem.
i have one table named "employee" . i have two triggers defined on insert for this table .the following are the trigger definitions
CREATE TRIGGER ins_emp1
ON employees
FOR INSERT
AS
BEGIN
DECLARE @new_bill_cust_code char(16)
DECLARE Inserted_Cursor CURSOR FOR SELECT bill_cust_code FROM Inserted
OPEN Inserted_Cursor
FETCH NEXT FROM Inserted_Cursor INTO @new_bill_cust_code
WHILE @@FETCH_STATUS = 0
BEGIN
--executing some procedue
EXECUTE add_emp_bill_code @new_bill_cust_code
FETCH NEXT FROM Inserted_Cursor INTO @new_bill_cust_code
END
CLOSE Inserted_Cursor
DEALLOCATE Inserted_Cursor
END
GO
CREATE TRIGGER ins_emp2
ON employees
FOR INSERT
AS
BEGIN
DECLARE @new_fee_cust_code char(16)
DECLARE Inserted_Cursor CURSOR FOR SELECT fee_cust_code FROM Inserted
OPEN Inserted_Cursor
FETCH NEXT FROM Inserted_Cursor INTO @new_fee_cust_code
WHILE @@FETCH_STATUS = 0
BEGIN
--executing some procedue
EXECUTE add_emp_fee_code @new_fee_cust_code
FETCH NEXT FROM Inserted_Cursor INTO @new_fee_cust_code
END
CLOSE Inserted_Cursor
DEALLOCATE Inserted_Cursor
END
GO .
when i perform an insert from the query analyzer i am getting the following error .
Server: Msg 16915, Level 16, State 1, Procedure upd_cnucustr, Line 17
A cursor with the name 'Inserted_Cursor' already exists.
The statement has been terminated.
.
I guess some of you should have come through similar circumstances .
Thanks
Rajeev
March 25, 2002 at 6:51 am
March 25, 2002 at 9:27 pm
yes ,i was thinking by default its local ,but then i saw that all that depends on the database setting default_cursor local|global .So i declared each trigger as
local so there by the whole issue could be solved .Thanks andy for spending time
March 26, 2002 at 5:20 am
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply