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
What are literals in sql server?
What is input buffer in sql*plus?
What is spool?
What are the steps for performance tuning.
What is the most important ddl statements in sql are?
What is a natural join?
Is not null in sql?
How do I find duplicates in sql?
Explain what is a database?
Which join is like inner join?
Is truncate ddl or dml?
give the syntax of grant and revoke commands? : Sql dba
What is difference between cursor and trigger?
How do you create an update query?
Can you call pl/sql package functions from within a fast formula?