General discussion


question on SQL trigger

By Hunterzh ·
I??m programming with T-SQL, to create a trigger as the following:
create trigger orderinsert_price
on seorderentry
for insert,update
declare @band varchar(20)
select @band=t1.f_103
from inserted s1,seorder s2,t_item3012 t1
where s1.finterid=s2.finterid
and s2.fcustid=t1.f_101
and s1.fitemid=t1.f_102

update seorderentry
set fprice=
(case @band
when 'A' then t2.f_103
when 'B' then t2.f_104
else 0
from inserted s1, t_icitem t2
where s1.fitemid=t2.fitemid
but it always prompts me that f_103 and f_104 are invalid column names.
Does it have any logical problem for the above? You needn't pay attention to details, just the main structure.

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by vladislav.macek In reply to question on SQL trigger

It's a long time I've ceased to work with T-SQL, so I am not sure the syntax is correct, but you cannot launch another update process in the update trigger. Use something like this:
set @somevalue, @anothervalue using select;
modify the (case @band
when 'A' then new.fprice = @somevalue
when 'B' then new.fprice = @anothervalue
else 0

Collapse -

by Hunterzh In reply to question on SQL trigger

This question was closed by the author

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums