Home » SQL & PL/SQL » SQL & PL/SQL » insert into two tables from one query
insert into two tables from one query [message #195375] Thu, 28 September 2006 05:24 Go to next message
oracle_coorgi
Messages: 185
Registered: September 2006
Location: INDIA-karnataka
Senior Member
hi

i need to insert data into two tables from one single query

eg table: test1(col1,col2) test(col3,col4)

thanxs

Re: insert into two tables from one query [message #195377 is a reply to message #195375] Thu, 28 September 2006 05:32 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I can't think of a way to do it as part of the query.

You could create an After Insert trigger on one of the tables to insert the data into the other table.

Why do you need to be able to do this?
Re: insert into two tables from one query [message #195400 is a reply to message #195375] Thu, 28 September 2006 07:14 Go to previous messageGo to next message
gguzdziol
Messages: 2
Registered: September 2006
Junior Member
Something like

insert all
into test1 (col1, col2)
values (col1, col2)
into test(col3, col4)
values (col3, col4)
select 1 col1, 2 col2, 3 col3, 4 col4
from dual
Re: insert into two tables from one query [message #195406 is a reply to message #195400] Thu, 28 September 2006 07:53 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Good grief. so it does.
Previous Topic: Working with elements in a concatenated field
Next Topic: Need help on sorting dates in a column
Goto Forum:
  


Current Time: Thu Dec 08 08:43:58 CST 2016

Total time taken to generate the page: 0.10288 seconds