|
|
sybperl-l Archive
Up Prev Next
From: michael dot peppler at bnpparibas dot com
Subject: Re: Syntax example of an Inset statement where it is selecting values from
another table
Date: Mar 22 2006 3:14PM
You can do exactly the same thing in DBI - just submit the entire request:
$sth = $dbh->prepare("insert table (....) select ....from ... where ...");
$sth->execute;
...
Nothing magic about it at all!
Michael
Internet
Robert_Gorrebeeck@concentra.com@peppler.org - 22/03/2006 16:05
Sent by: owner-sybperl-l@peppler.org
To: sybperl-l
cc:
Subject: Syntax example of an Inset statement where it is selecting
values from another table
All
I am wondering if anyone has an example of an Inset statement where it is
selecting values from another table.
So for example in sql or a stored proc it would look like this
Insert into table a (column1,
column2,
column3,
column4
select( column1,
column2,
column3
column4
from table b
But am not sure of the syntax when using DBI
I know when I want to insert a row I can do this, but am not sure of the
syntax when I want to grab a bunch of rows from one table and insert them
into another.
$sth=$dbh->prepare(qq{INSERT INTO table b(column1, column2, column3,
column4) VALUES (?, ?, ?, ?)});
I guess one solution is to loop thru the rows that I get returned via a
select statement but that seems like a waste of processing time
Any help would be appreciated
Robert Gorrebeeck
Concentra Online Services
972.725.6956
Robert_Gorrebeeck@concentra.com
****** CONFIDENTIALITY NOTICE ******
NOTICE: This e-mail message and all attachments transmitted with it may
contain legally privileged and confidential information intended solely for
the use of the addressee. If the reader of this message is not the intended
recipient, you are hereby notified that any reading, dissemination,
distribution, copying, or other use of this message or its attachments is
strictly prohibited. If you have received this message in error, please
notify the sender immediately and delete this message from your system.
Thank you.
This message and any attachments (the "message") is
intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
---------------------------------------------
Ce message et toutes les pieces jointes (ci-apres le
"message") sont etablis a l'intention exclusive de ses
destinataires et sont confidentiels. Si vous recevez ce
message par erreur, merci de le detruire et d'en avertir
immediatement l'expediteur. Toute utilisation de ce
message non conforme a sa destination, toute diffusion
ou toute publication, totale ou partielle, est interdite, sauf
autorisation expresse. L'internet ne permettant pas
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce
message, dans l'hypothese ou il aurait ete modifie.
|