开发者

Trigger Procedures

开发者 https://www.devze.com 2023-02-11 03:53 出处:网络
I need to call a trigge开发者_Python百科r when a column is updated in table X Trigger is inserting values from table X to table Y

I need to call a trigge开发者_Python百科r when a column is updated in table X Trigger is inserting values from table X to table Y can we just insert the values in X to Y using the column names in X?


Something like this perhaps?

create trigger tr_U_X 
on X
for Update
as
begin
    if update(email)
        insert into Y
            (name, email)
            select i.name, i.email
                from Inserted i
end


You can add below code to add trigger

CREATE OR REPLACE TRIGGER Trigger_Name BEFORE 

INSERT OR DELETE OR UPDATE 

ON table_name REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW

BEGIN

if condition > 0 then
         raise_application_error(-20010,'your message');
    end if;

END;

I have managed it my Financial ERP you can use it . Thank you .

0

精彩评论

暂无评论...
验证码 换一张
取 消