Hello
can we update the records in two tables at a time?
Like, we are able to select the records from two tables by means of join, how about with the case of update.
Thank you
Printable View
Hello
can we update the records in two tables at a time?
Like, we are able to select the records from two tables by means of join, how about with the case of update.
Thank you
no
Then, what is the other way how i can fix it?
Thank you
Let's say you want to update table 2 and table 3 at the same time table 1 is updated.
You create a trigger "ON UPDATE" on table 1 and in that trigger you update table 2 and table 3.
how about create a view joining 2 tables, and update this VIEW will update these 2 underlined tables
could you please be more clear and tell me how should i proceed.can you give me the syntax.
Thank you
Example:
create view YourView
as
select ...
from YourTable1
, YourTable2
where (join-clause)
create or replace trigger YourTrigger
INSTEAD OF DELETE OR INSERT OR UPDATE
ON YourView
declare
--
begin
if inserting
then
-- Insert statements
insert into YourTable1
( column11)
values
(:new.viewcolumn)
;
insert into YourTable2
( column21)
values
(:new.viewcolumn)
;
elsif updating
then
update YourTable1
set column11 = :new.viewcolumn1
where column12 = :new.viewcolumn2
;
update YourTable2
set column21 = :new.viewcolumn1
where column22 = :new.viewcolumn3
;
elsif deleting
then
...
end if; -- inserting/updating/deleting
end;