do() with bind_values

From: Jupiterhost.Net (mlists_at_jupiterhost.net)
Date: 05/12/04


Date: Wed, 12 May 2004 09:13:11 -0500
To:  dbi-users@perl.org

Howdy group!

perldoc DBI
has this:
    $rv = $dbh->do($statement, \%attr, @bind_values);

So would this be a proper use of it:

  $dbh->do(
    'INSERT INTO Stuff (Id,Foo) VALUES (NULL,?)',
     undef,
     qw('foo' 'bar' 'baz')
  ) or die ....
# IE undef foro \%attr and include quoted data

That would essencially run:
  INSERT INTO Stuff (Id,Foo) VALUES (NULL,'foo');
  INSERT INTO Stuff (Id,Foo) VALUES (NULL,'bar');
  INSERT INTO Stuff (Id,Foo) VALUES (NULL,'baz');
since do() does the prepare and execute for you.
correct?

TIA

Lee.M - JupiterHost.Net



Relevant Pages

  • Re: My editfile.pl script
    ... If you don't know what a lexical filehandle is, ... my $before = undef; ... die $usage unless $line; ...
    (comp.lang.perl.misc)
  • Re: using $! for die()ing with Package function
    ... Jonathan Paton wrote: ... I prefer undef for false. ... bazor die $!; ... sub baz { ...
    (perl.beginners)
  • Re: local *FH
    ... open FH,$path or return undef; ... Because local would protect the global file-handle FH which maybe was ... open HD,'/etc/resolv.conf' or die $!; ...
    (perl.beginners)
  • problems mime::lite
    ... a small end of code contains die ... sub SEND_MAIL{ ... if($attachement eq undef){ ... Filename => 'attachement.gif' ...
    (comp.lang.perl.misc)
  • Re: Quotes and apostrophes assistance
    ... "SELECT foo FROM bar where path=?", ... No need for die() if you set up the $dbh with 'RaiseError' on, ...
    (perl.beginners)