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 do you write a complex sql query?

581


Which type of cursor is used to execute the dml statement?

526


how many ways to get the current time? : Sql dba

524


Explain table and field in sql?

576


What is not null in sql?

571






How can you fetch common records from two tables?

585


What are the different parts of a package?

629


What is nosql db?

536


What is insert command in sql?

522


What is dcl in sql?

524


What is indexing in sql and its types?

537


How to handle bulk data?

889


what is offset-fetch filter in tsql? : Transact sql

530


How does index help in query performance?

558


What is the difference between view and stored procedure?

490