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: Return value of $dbh->prepare() on error
    ... The primary documentation (CPAN and perldoc DBI) don't say. ... the behaviour of the test program shows it returning what appears to be the ... What is the correct behaviour? ... prepareshould return undef if it failed. ...
    (perl.dbi.users)
  • Re: question on de-referencing expressions
    ... TZ> It's worth noting here that if the returned value is undef, ... TZ> will die here. ... Note that the first test ... Can't use an undefined value as a HASH reference at -e line 1. ...
    (comp.lang.perl.misc)
  • 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: question on de-referencing expressions
    ... TZ> It's worth noting here that if the returned value is undef, ... TZ> will die here. ... Note that the first test ...
    (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)