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
What are the uses of merge?
how to show all tables with 'mysql'? : Sql dba
what is a view? : Sql dba
Can you sum a count in sql?
what is sql profiler? : Sql dba
How do I order by ascending in sql?
Why sql query is slow?
How many types of normalization are there?
What is the difference between delete and truncate statement in sql?
column A column b | output 10 7 | 10 5 8 | 8 7 -9 | 7 3 5 | 5 0 6 | 6 Write a sql query to print such output.
what are date and time data types? : Sql dba
What is a relationship and what are they?
What does select top 1 do in sql?
What problem one might face while writing log information to a data-base table in pl/sql?
which command using query analyzer will give you the version of sql server and operating system? : Sql dba