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


Please Help Members By Posting Answers For Below Questions

What are literals in sql server?

650


What is input buffer in sql*plus?

724


What is spool?

680


What are the steps for performance tuning.

932


What is the most important ddl statements in sql are?

623






What is a natural join?

620


Is not null in sql?

646


How do I find duplicates in sql?

601


Explain what is a database?

730


Which join is like inner join?

666


Is truncate ddl or dml?

638


give the syntax of grant and revoke commands? : Sql dba

706


What is difference between cursor and trigger?

653


How do you create an update query?

621


Can you call pl/sql package functions from within a fast formula?

669