これが私のトリガーです
Create TRIGGER [dbo].[tri_before_update]
ON [dbo].[test]
instead of update
AS
BEGIN
SET NOCOUNT ON;
if update (test_a)
begin
*.. my update & insert query*
end
END
create TRIGGER [dbo].[tri_before_update_price]
ON [dbo].[co_ticket]
instead of update
AS
BEGIN
SET NOCOUNT ON;
if update (t_price)
begin
insert into old_price_log (t_id,insert_time,process_id,old_t_price)
select i.t_id,getdate(),2,t_price
from Inserted i,co_ticket t where i.t_id = t.t_id
update t set t_price = i.t_price
from co_ticket t, inserted i
where t.t_id = i.t_id
end
else
begin
-- if update other then (t_price) then the update comand not execute.
-- example when i update t_cancel_flag or t_quantity and etc. end
END
このトリガーは、列「test_a」を更新すると完全に実行されます。ただし、列「test_a」以外を更新すると実行されません。「else」コマンドを入力できることはわかっていますが、列がたくさんあります。他の 2 つの列を更新することもあれば、3 つまたは 4 つの列を更新することもあります。毎回すべての列を更新したくありません。ELSE「その後、元のクエリを実行する」ことは可能ですか? 私は多くの異なる方法を試しましたが、まだうまくいきません。:( 助けてください!