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
when MSQL8.0 is in market
What is cursor explain with example?
How to convert comma separated string to array in pl/sql?
How do I edit a trigger in sql developer?
What is oracle pl sql developer?
What is trigger types of trigger?
What is procedure in pl sql?
what is isam? : Sql dba
What are sql ddl commands?
How much does sql cost?
What is a pragma statement?
What is the difference between row level and statement level trigger?
How do I run a sql query?
When are we going to use truncate and delete?
What is numeric function sql?