Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Explain isolation levels. : Transact sql

1077


Can we join 3 tables in sql?

1053


What is embedded sql with example?

1058


what are the maximum number of rows that can be constructed by inserting rows directly in value list? : Transact sql

961


How do I write a cron which will run a sql query and mail the results to agroup?

992


What does desc stand for?

1076


What do you mean by table in sql?

999


Explain lock escalation? : Transact sql

1210


how to select unique records from a table? : Sql dba

1120


What is the use of sqlerrd 3?

947


What is int identity in sql?

1152


What is plpgsql language?

1070


Why functions are used in sql?

999


What is the process of copying data from table a to table b?

1097


what is 'mysqldump'? : Sql dba

1115