no, the @bind_values is a list to bound for that statement. It could 1
or many (i.e. if you have where id = ? and date = ? ). If you have a
list of values that need to be inserted into different rows, then
iterate through the array and execute the 'do'. A word of caution, if
the list is going to be big, "pre-prepare" you're statement for
preformance issues. Although some databases do not support this, it is
good coding practice and will make a big effect on performance if the
code is used with another database, such as Oracle.
i.e.
for (@vals) {
$dbh->do(
'INSERT INTO Stuff (Id,Foo) VALUES (NULL,?)',
undef,
$_
) or die ....
}
On Wed, 2004-05-12 at 09:13, JupiterHost.Net wrote:
> 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