Kipp, James [[EMAIL PROTECTED]] wrote:
> > >
> > > $dbh->prepare( "INSERT INTO tbl_people ( lastname ) VALUES (?)" );
> >
> > This should be
> >
> > $sth = $dbh->prepare( "INSERT INTO tbl_people ( lastname )
> > VALUES (?)" );
>
> ok. What is the function of the '?' for values ?
> can I subsistute a variable (VALUES ($name)"?
You can, but then you have to worry about properly quoting the
variable. It's *MUCH* safer and easier to use the ?(placeholder).
Read up on placeholders in the book, or do "perldoc DBI" and search
for "placeholder".
>
> >
> > >
> > > 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);
>
> woops! :-)
>
> >
> > 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.
>
> Yes, I plan to do that. I just want to get some of the table manipulation
> techniqes down first. But I do have RaiseError set:
> ### The database handle
> my $dbh = DBI->connect( dbi:Oracle:prj_test.ftbee01a","xx","xx", {
> RaiseError => 1
> });
That's good!
--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com