See below.
--
Mac :})
** I normally forward private database questions to the DBI mail lists. **
Give a hobbit a fish and he'll eat fish for a day.
Give a hobbit a ring and he'll eat fish for an age.
----- Original Message -----
From: "Tony Foiani" <[EMAIL PROTECTED]>
To: "Jim Lynch" <[EMAIL PROTECTED]>
Cc: "dbi-users" <[EMAIL PROTECTED]>
Sent: Wednesday, February 07, 2001 12:57 PM
Subject: Re: How do I form an acceptable string for an IN clause?
> Another way to construct a reasonable "IN" clause is to use the
> DBI::quote method:
>
> | my @vals = ('foo', "bar", "baz's");
> | my $set = join ', ', map $dbh->quote($_), @vals;
> | my $sql = "SELECT whatever FROM wherever WHERE somecolumn IN ($set)";
>
> Note that this will properly handle the single quote in the third
> value.
>
> Using multiple placeholders will also work, although I'd be surprised
> if the total number of placeholders in any given statement can be all
> that high.
I've used over 50 placeholders in some Oracle SQL statements. If I'd tried
to put that many literals in the statement I'd have hit the upper bound to
the number of characters allowed in a SQL statement; you can fit a lot more
?s in there than you can fit full strings for the same number of arguments.
This is especially noticeable when some of the strings are very long. Also,
$dbh->quote() sometimes has problems with odd characters.