Kipp, James [[EMAIL PROTECTED]] wrote:
> Hello
> 
> I am quite new to DBI and I am learning from the Perl DBI Book. It does not
> cover inserting data in detail. I am just wondering the best way to insert
> many values into a field. I know it is something like:
> 
> $dbh->prepare( "INSERT INTO tbl_people ( lastname ) VALUES (?)" );

This should be

  $sth = $dbh->prepare( "INSERT INTO tbl_people ( lastname ) VALUES (?)" );

> 
> How do I have it iterate through an array of names ?
> 
> foreach $name (qw( Smith Jones Roberts Johsnon Fredericks) ) {
>       sth->execute($name);

And this should be

        $sth->execute($name);

> }


Also, I see that you're not error checking your dbi statements -
hopefully you have RaiseError set to 1(on).  Read the perldocs
on DBI - Error checking is explained in detail there - do

  perldoc DBI

to see.  Search for RaiseError.

HTH.

Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

Reply via email to