SPUG: Turning off auto-quoting during DBI Binding.

Colin Meyer cmeyer at helvella.org
Mon Apr 7 20:37:58 PDT 2008

Hi Stephen,

DBI "?" placeholders may only represent single, scalar values. With most
DBD drivers, the substitution of values for ? placeholders is not a
simple string interpolation.

Have a look at 'perldoc DBI' and search for "Placeholders and Bind Values".

    Also, placeholders can only represent single scalar values. For
    example, the following statement won?t work as expected for more
    than one value:

         "SELECT name, age FROM people WHERE name IN (?)"    # wrong
         "SELECT name, age FROM people WHERE name IN (?,?)"  # two names


On Mon, Apr 07, 2008 at 08:30:35PM -0700, Stephen Blum wrote:
> Hey SPUG Team,
> How does one turn off the annoying and sometimes unneeded auto-quoting that occurs during DBI Bindings?  I have searched the net for a while now and have found little on the subject.
> example:
> $sql = q(thrrr_id in (?));
> $sth = $dbh->prepare($sql);
> $sth->execute( q(1,2,3,4,5) );
> DBI executes this:           thrrr_id in ('1,2,3,4,5') 
> But I want to execute this:  thrrr_id in (1,2,3,4,5) 
> DBI adds quotes and I don't want them.  If there is no way around this I can forgo the performance/convenience of bindings.
> Thank you SPUG Team!
> Stephen
> _____________________________________________________________
> Seattle Perl Users Group Mailing List  
>      POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>     MEETINGS: 3rd Tuesdays
>     WEB PAGE: http://seattleperl.org/

More information about the spug-list mailing list