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 the unique index?
How many parts of a pl sql block are optional?
Does truncate remove indexes?
Does truncate require commit?
What is the example of procedure?
Which query operators in sql is used for pattern matching?
Is drop table faster than truncate?
how to use myisamchk to check or repair myisam tables? : Sql dba
How do I view a sql trace file?
What is a scalar value in sql?
What is sql in java?
What is dynamic query?
What are the string functions in sql?
Can we create view in stored procedure?
What are the different types of tables in sql?