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 different types of tables in sql?
define join and explain different type of joins? : Sql dba
What is recursive join in sql?
What is the maximum number of columns in sql table?
what are the differences between get and post methods in form submitting. Give the case where we can use get and we can use post methods? : Sql dba
What are crud methods?
What is fmtonly in sql?
What is the purpose of a sql?
What is set serveroutput on in pl sql?
Why do we need pl sql?
What is the difference between a query and a report?
Why is partition used in sql?
What are the advantages of stored procedure?
What are aggregate functions in sql?
How does index help in query performance?