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
How do you write a complex sql query?
Which type of cursor is used to execute the dml statement?
how many ways to get the current time? : Sql dba
Explain table and field in sql?
What is not null in sql?
How can you fetch common records from two tables?
What are the different parts of a package?
What is nosql db?
What is insert command in sql?
What is dcl in sql?
What is indexing in sql and its types?
How to handle bulk data?
what is offset-fetch filter in tsql? : Transact sql
How does index help in query performance?
What is the difference between view and stored procedure?