Is there a reason you need to make the round trip from the database,
through your program, and then back to the database? If not then just
do an insert select:
my $sql = "insert into table2 select null, col2, col3, col4 from table1
where col1 = ?";
$dbh->do($sql);
-Original Message-
From
Do these selects first and push the results into an array of arrays. Then
prepare your insert and loop through your array on the execute portion
only. Short of multiline inserts that should be your fastest way to do
things.
Doesn't this (below) affect my ability to do that?
I don't really know.
At 02:13 PM 4/26/2005, Jonathan Mangin wrote:
- Original Message - From: "Eric" <[EMAIL PROTECTED]>
To: "Jonathan Mangin" <[EMAIL PROTECTED]>;
Sent: Tuesday, April 26, 2005 3:43 PM
Subject: Re: Efficient select/insert
At 01:13 PM 4/26/2005, Jonathan Mang
- Original Message -
From: "Eric" <[EMAIL PROTECTED]>
To: "Jonathan Mangin" <[EMAIL PROTECTED]>;
Sent: Tuesday, April 26, 2005 3:43 PM
Subject: Re: Efficient select/insert
At 01:13 PM 4/26/2005, Jonathan Mangin wrote:
I would like to select several row
At 01:13 PM 4/26/2005, Jonathan Mangin wrote:
I would like to select several rows from one table
and insert them into another nearly identical table
using Perl/DBI:
my @array = $q->param(); # HTML checkboxes
foreach my $element (@array) {
my $sql = "select col2, col3, col4 from table1
- Original Message -
From: "Philip M. Gollucci" <[EMAIL PROTECTED]>
To: "Jonathan Mangin" <[EMAIL PROTECTED]>
Cc:
Sent: Tuesday, April 26, 2005 3:19 PM
Subject: Re: Efficient select/insert
Jonathan Mangin wrote:
I would like to select several rows fro
$dbh->do("INSERT INTO t (col1, ...) SELECT col1, ... FROM t2 WHERE x
= '$element'");
Oi SQL injection warning! Red lights and sirens - don't do that!!
'$element' is supper dangerouse, evil evil evil
either $dbh->quote it or use ? in your prepare/execute dance:
$dbh->do( 'INSERT INTO t (col
This is very inefficient ...
1. You are prepare()ing your SQL statements in a loop.
2. You are performing row-at-a-time processing
Move your SQL statements out the loop. This will be a big performance gain (in
a high transaction app).
However (in Oracle), this would best be accomplished by .
Jonathan Mangin wrote:
I would like to select several rows from one table
and insert them into another nearly identical table
using Perl/DBI:
my @array = $q->param(); # HTML checkboxes
foreach my $element (@array) {
$dbh->do("INSERT INTO t (col1, ...) SELECT col1, ... FROM t2 WHERE x
= '$eleme