Multiple insert through one Query
Posted in 2006
Topics: Migration, Import/Export & Data Conversion
Hi Everybody,
I have to write a Database Script, In which values from one tables are
inserted into another table.
Now the query format something like this
Insert into table a values (select * from temp_a where a_condition = 1)
Now if the query *select * from temp_a where a_condition = 1 *returns
single row then its fine.
But here query is returning multiple row, is there any way to insert into
table multiple row .
one way is
Unload to "fileName" Select * from table
Load from "fileName" Insert into table.I could have used above unload approach but it would create one file, which
i am not supposed to do.
--
Regards,
Prateek Jain
Prateek Jain wrote:
> I have to write a Database Script, In which values from one tables are
> inserted into another table.
> Now the query format something like this
>
> Insert into table a values (select * from temp_a where a_condition = 1)
That works? If it returns one row - well, I can see how it works, but
I'm surprised it is allowed.
> Now if the query *select * from temp_a where a_condition = 1 *returns
> single row then its fine.
> But here query is returning multiple row, is there any way to insert
> into table multiple row .
INSERT INTO TableA SELECT * FROM Temp_A WHERE a_condition = 1
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2005.02 -- http://dbi.perl.org/
Prateek Jain wrote: > Hi Everybody, > I have to write a Database Script, In which values from one tables are > inserted into another table. <snip> May I suggest some reading, http://publib.boulder.ibm.com/infocenter/idshelp/v10/topic/com.ibm.sqlt.doc/sqltmst138.htm
Rich or Kristín wrote: > Prateek Jain wrote: > > Hi Everybody, > > I have to write a Database Script, In which values from one tables are > > inserted into another table. > <snip> > > May I suggest some reading, > http://publib.boulder.ibm.com/infocenter/idshelp/v10/topic/com.ibm.sqlt.doc/sqltmst138.htm very nice way to say RTFM.
bozon wrote: > very nice way to say RTFM. I have every confidence that now the user knows where to find TFM he will be sure to R it ;-)