INSERT INTO multiple tables

INSERT INTO multiple tables

Post by neol.. » Thu, 26 Oct 2000 04:00:00



Hello !

I need to preform one insert into two tables.
Can I make somethink like that:

INSERT INTO Table1 t1, Table2 t2 ( t1.field1, t2.field2 )
VALUES ( 23, 34 )

On which Databasesystems does this work ?
I'm working with Oracle 8.05

Thanks
 neolynx

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

INSERT INTO multiple tables

Post by Art S. Kage » Sat, 28 Oct 2000 02:33:00



> Hello !

> I need to preform one insert into two tables.
> Can I make somethink like that:

> INSERT INTO Table1 t1, Table2 t2 ( t1.field1, t2.field2 )
> VALUES ( 23, 34 )

Can't do it.  Try:

INSERT INTO table1 (field1) values (23); INSERT INTO table2 (field2) values
(24);

as a multiple statement block, or wrap a transaction around the two inserts
if atomicity is needed:

BEGIN WORK;
INSERT INTO table1 (field1) values (23);
INSERT INTO table2 (field2) values (24);
COMMIT WORK;

Art S. Kagel

Quote:> On which Databasesystems does this work ?
> I'm working with Oracle 8.05

> Thanks
>  neolynx

> Sent via Deja.com http://www.deja.com/
> Before you buy.


 
 
 

INSERT INTO multiple tables

Post by Edwar » Sat, 28 Oct 2000 17:28:48


You could make a stored procedure with 6 parameters
(table1,table1,field1,field2,value1,value2)

create or replace procedure do_insert (p_table1 in varchar2,...)
begin
 insert into p_table1 (p_field1) values (p_value1);
 insert into p_table1 (p_field1) values (p_value1);
end;

from pl/sql there's only one statement left:
do_insert(..,..,..,..);

or SQLplus:
exec do_insert(..,..,..,..);


Quote:> Hello !

> I need to preform one insert into two tables.
> Can I make somethink like that:

> INSERT INTO Table1 t1, Table2 t2 ( t1.field1, t2.field2 )
> VALUES ( 23, 34 )

> On which Databasesystems does this work ?
> I'm working with Oracle 8.05

> Thanks
>  neolynx

> Sent via Deja.com http://www.deja.com/
> Before you buy.

 
 
 

1. newbie query question: Inserting into multiple tables

Hi-

I have a 'Products' table and a 'Products_Images' table.
On my 'Add Product' page, I would like to insert the new data into those two
tables, but I don't think I have ever seen the syntax for this, is it
possible?

Here is an example of my data
[Products].[PartNum] (pk)

[Products_Images].[PartNum] (fk)
[Products_Images].[ImgSrc] (nvarchar)

so, I need to get a value into ImgSrc as well as PartNum in both tables.
Hope that makes sense?

Thanks-
Steve

2. ComboBox Problem!

3. Inserting into multiple tables, keep the relations.

4. Listview Control

5. Insert into multiple tables via XML

6. Consultant rates, midwest/small urban areas vs. coasts/big urban areas

7. INSERT on Multiple Tables

8. VB Script & DTS

9. Inserting into multiple tables

10. Insert into multiple tables via XML

11. Insert Into Multiple tables using Lookup

12. Inserting into multiple tables using identity fields

13. Inserting into multiple tables with sp