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
explain access control lists. : Sql dba
Does a primary key have to be a number?
How do you delete a table?
What does the base_object_type column shows in the user.triggers data dictionary view?
Are pl sql variables case sensitive?
What is pl/sql language case sensitive?
Does sql between include endpoints?
Are sql database names case sensitive?
What is auto increment in sql?
What are secondary keys?
What is rownum in sql?
What is synonyms?
Is left join faster than join?
What is the difference between local variables and global variables?
which operator is used in query for pattern matching? : Sql dba