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 tsql statements can be written and submitted to the database engine? : Transact sql

533


What are sql objects?

539


Can we want to pass a parameter payroll_id to this external pl/sql function, how do we do it?

556


What are the triggers associated with image items?

619


What is sql not null constraint?

603






What is the difference between Union and Union all. Which is faster.

844


what is view? : Sql dba

556


Suppose a student column has two columns, name and marks. How to get name and marks of the top three students.

527


Enlist the characteristics of pl/sql?

1240


What is difference between my sql and sql?

529


Explain the difference between 'between' & 'and' operators in sql

527


Can we insert data into materialized view?

513


how many sql dml commands are supported by 'mysql'? : Sql dba

569


What is pl sql block structure?

543


How do I view tables in sql developer?

516