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 does trigger mean in slang?
What is pl sql script?
Do we need to create index on primary key?
Why do we create stored procedures & functions in pl/sql and how are they different?
What is trigger types of trigger?
how to increment dates by 1 in mysql? : Sql dba
What do you mean by stored procedures?
Is there a pl/sql pragma similar to deterministic, but for the scope of one single sql select?
How does left join work in sql?
How is debugging done?
If i can use sys.check_constraints to display my constraints from my database using sql server 2005, how can i display then if i am using sql server 2000????
What is a database trigger?
Why do we need unique key in a table?
What does (+) mean in sql joins?
Can we use delete in merge statement?