If i insert record in table A and these record should update in table B by using Trigger.How to achieve this.

Answer Posted / abhishek jaiswal

Table 1(U_register)
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 FIRST_NAME                 PK                        VARCHAR2(15)
 LAST_NAME                                 NOT NULL VARCHAR2(15)
 DOB                                       NOT NULL DATE
 USER_NAME                                 NOT NULL VARCHAR2(15)
 NEW_PASSWORD                              NOT NULL VARCHAR2(15)
 CONFIRM_PASSWORD                          NOT NULL VARCHAR2(15)
 U_ID                                      NOT NULL NUMBER

Table 2(Login_detail)

 Name                                      Null?    Type
 -------------------------FK---------------- -------- ----------------------------
 ID                                        NOT NULL NUMBER
 USER_NAME                                          VARCHAR2(15)
 NEW_PASSWORD                                       VARCHAR2(15)

Now,We have to write trigger to insert of column 'user_name' and 'new_password' in login_detail table.
To do this we will use After insert trigger.

create or replace 
trigger tgr_login
after insert on u_register
for each row
begin 
insert into login_detail
values (:new.u_id,:new.user_name,:new.new_password);
end tgr_login;

---and It will work .

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does pl sql work?

515


explain the difference between bool, tinyint and bit. : Sql dba

517


what are the join types in tsql? : Transact sql

568


can a stored procedure call itself or recursive stored procedure? : Sql dba

573


How does a self join work?

511






What are all different types of collation sensitivity?

523


what is error ora-03113: end-of-file on communication channel?

595


What is meant by <> in sql?

499


what are date and time data types? : Sql dba

532


Which table is left in left join?

514


What is the purpose of the primary key?

560


How to read/write files from pl/sql?

577


what is a database transaction? : Sql dba

577


what is a stored procedure? : Sql dba

544


How to add a column ‘salary’ to a table employee_details?

579