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 is rename in sql?
What are pl/sql cursor exceptions?
What is a table in a database?
How is use pl and sql?
What is data type in database?
What is the difference between left outer join and left join?
What are different types of tables in sql?
Explian rowid, rownum? What are the psoducolumns we have?
How do you delete data from a table?
What is mdb stand for?
What is the difference between python and sql?
Explain how you can copy a file to file content and file to pl/sql table in advance pl/sql?
How do I add a database to sql?
How to execute a stored procedure?
what is self-join? : Sql dba