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
Explain isolation levels. : Transact sql
Can we join 3 tables in sql?
What is embedded sql with example?
what are the maximum number of rows that can be constructed by inserting rows directly in value list? : Transact sql
How do I write a cron which will run a sql query and mail the results to agroup?
What does desc stand for?
What do you mean by table in sql?
Explain lock escalation? : Transact sql
how to select unique records from a table? : Sql dba
What is the use of sqlerrd 3?
What is int identity in sql?
What is plpgsql language?
Why functions are used in sql?
What is the process of copying data from table a to table b?
what is 'mysqldump'? : Sql dba