On 10 Mar 2003 14:34:28 -0600 Rob Benton <[EMAIL PROTECTED]> wrote:

> OK I see what you're doing.  What I would need to do is just tweak that
> a little.  I would need something like:
> 
> foearch ($cgi->param() ) {
>         if ( <some test on the type here> ) {
>                 $dbh->quote($_);
>         }
>         $sql .= "$_,";
>         $val .= "?,";
>         push(@{$array_ref}, $cgi->param($_));
> }
> 
> Does that make any sense?

No.

If you are using placeholders, quote() is not necessary and *should
not* be used.  That is one of the advantages of placeholders.
Read up on them in the fine DBI manual.

Again read http://xmlproj.com/fom-serve/cache/49.html .

# Untested example, there is always more than one way to do it
$dbh -> {RaiseErrors} = 1;  # Error checking is essential
my ( @cols, @vals ) = ();
foreach ( $cgi->param() ) {
   push @cols, $_;
   push @vals, $cgi -> param( $_ );
}
# Note: Under Oracle, a SQL statement that is *IDENTICAL* to a
# previously parsed statement does not have to be replanned.
my $sql = "INSERT INTO table ( " . join( ", ", @cols ) . " )\n" .
   "   VALUES ( " . join( ", ", map { "?" } @cols ) . " )";
my $sth = $dbh -> prepare( $sql );
$sth -> execute( @vals );
$dbh -> commit();

-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Reply via email to