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
What is sql dialect?
what are set operators in sql? : Sql dba
What are character functions in sql?
how tsql statements can be written and submitted to the database engine? : Transact sql
Explain how can you save or place your msg in a table?
What is inner join in sql?
What does where 1/2 mean in sql?
Describe types of sql statements?
What is the maximum number of rows in sql table?
What is the requirement of self-join?
what is data manipulation language? : Sql dba
What is the trigger in sql?
How do you truncate?
Which tcp/ip port does sql server run?
what are the differences between procedure-oriented languages and object-oriented languages? : Sql dba