Small question.
If i have a trigger
crate trigger aTrigger on b after update
as
declare @con1 int
declare @con2 varchar(10)
declare cur CURSOR
for select con1,con2 from updated
fetch NEXT from cur into @con1 , @con2
while (@@fetch_status = 0)
begin
if(@con1 not in (1,2) )
begin
delete from tableC where con1 = @Con1 and Con2 = @con2
end
/*now here is the tricky part , because this trigger also must delete from table C if the con1 is not 1 or 2 I must insert into TableC or Update an excisting record*/
else
begin
if excists (select * from tablec where con1 = @con1 and con2 = @con2)
begin
update tableC set con1 = @con1 , con2 =@con2, column3 = updated.column3
/*When i try to referance the updated.column3 i get an error saying that must use variables inside my cursor*/
end
else
begin
insert into tableC set(con1 , con2 =, column3 )
values(@con1 , @con2 , updated.column3)
/*same error as in the updated above*/
end
end
fetch next from cur into @con1, @con2
end