Home » Developer & Programmer » Forms » Doubt in sql
Doubt in sql [message #85529] Tue, 06 July 2004 05:48 Go to next message
uma
Messages: 67
Registered: May 2001
Member
Is it possible to insert a record into 2 tables using a single SQL Statement,if it is possible pls let me know the solution.

Regards,
Uma Devi
Re: Doubt in sql [message #85532 is a reply to message #85529] Tue, 06 July 2004 06:05 Go to previous messageGo to next message
magnetic
Messages: 324
Registered: January 2003
Senior Member
possible.
build a databasetrigger on table A wich will fire when there is an insert.
the code in the trigger should insert into table B.
Re:another way but only after 9i [message #85538 is a reply to message #85529] Wed, 07 July 2004 01:53 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
you can use insert all to insert whatever columns into whatever tables you want

INSERT ALL
INTO emp1 VALUES(empno,ename,sal)
INTO emp2 VALUES(empno,job,hiredate)
INTO emp3 VALUES(empno,deptno,mgr)
SELECT empno,ename,sal,hiredate,mgr,deptno
FROM emp;
Re:another way but only after 9i [message #85560 is a reply to message #85538] Thu, 08 July 2004 07:11 Go to previous messageGo to next message
uma
Messages: 67
Registered: May 2001
Member
Hi Vamsi,
Thanks for ur reply, the query is working fine it is allowing us to insert in 2 table using single sql statement but it is inserting more than 1 record(based on the no of recs available in the select query) can u pls tell what's the reason for this
Re:another way but only after 9i [message #85563 is a reply to message #85560] Thu, 08 July 2004 07:51 Go to previous message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
hi uma,
need some more info.
like
ur select query
some data

by
vamsi
Previous Topic: Doubt in object group/libs
Next Topic: Doubt in constraints
Goto Forum:
  


Current Time: Wed May 15 19:58:20 CDT 2024