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

Answer Posted / abhishekjaiswal

Table 1(u_register) Parent table
 Name                                      Null?                           Type
 ----------------------------------------- -------- ----------------------
 FIRST_NAME                                                             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) Child table
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------
 ID                                        NOT NULL NUMBER
 USER_NAME                                          VARCHAR2(15)
 NEW_PASSWORD                                       VARCHAR2(15)

Now we will create trigger to insert column 'user_name','new_password' of u_register into column 'USER_NAME ','NEW_PASSWORD' of login_detail.We will use after insert trigger as 

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;

It will work for sure.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the best free sql database?

557


How do you copy a table in sql?

553


What is trigger in pl sql with examples?

511


Is sql sequential or random?

529


What is the difference between sql and mysql?

545






Why is sql*loader direct path so fast?

593


What is pl/sql table? Why it is used?

551


What is union and union all keyword in sql and what are their differences?

568


How can we make an if statement within a select statement?

529


What is transaction control language (tcl)?

626


What is a temp table?

561


What port does sql server use?

498


What is the use of procedures?

533


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

593


How do I view an execution plan in sql?

519