If i insert record in table A and these record should update in table B by using Trigger.How to achieve this.
Answer Posted / anil
CREATE table trg_tab
(ename VARCHAR(10),
sal NUMBER);
/
CREATE table log_tab
(usr VARCHAR(10),
upd DATE,
ename VARCHAR(10),
sal NUMBER
);
/
CREATE OR REPLACE TRIGGER log_trg
AFTER INSERT ON trg_tab
FOR EACH ROW
DECLARE
v_user VARCHAR(10);
BEGIN
SELECT USER
INTO v_user
FROm DUAL;
INSERT INTO log_tab
VALUES (v_user,SYSDATE,:NEW.ename,:NEW.sal);
END;
/
INSERT INTO trg_tab
SELECT ename,sal FROm emp;
/
SELECT * FROm log_tab;
/
Is This Answer Correct ? | 7 Yes | 1 No |
Post New Answer View All Answers
Is sql scripting language?
What is data type in sql?
Why are indexes and views important to an organization?
what is 'mysqlshow'? : Sql dba
What are the three forms of normalization?
What does truncate mean in sql?
Can we insert delete data in view?
How do you use join?
Is grant a ddl statement?
Can I learn sql in a week?
What is rank () in sql?
Can you have a foreign key without a primary key?
What are the types of index in sql?
what is user defined functions? : Sql dba
What are the different type of joins in sql?