in reply to Replacing DBI->do()
We must be looking at different documentations. When I look at the documentation of v1.631 of DBI for ->do, I see examples.
The examples do not match your code though, and I really wonder how your code compiles if it is supposed to be normal DBI code.
Maybe you want to learn about how DBI uses placeholders first?
I'm also unfamiliar with the SQL statement you seem to be using. I have never seen INSERT INTO ... SET foo=bar.
Also, you might want to read up on how DBI maps undef and NULL. A string NULL seems highly unlikely as a value for the column id.
Personally, I usually end up using the sequence of ->prepare, ->execute, ->finish:
my $dbh= DBI->connect('dbi:...', $user, $pass, { RaiseError => 1, Prin +tError => 0 }); # RaiseError is important so I can leave out all error handling my $sth= $dbh->prepare(<<'SQL'); INSERT INTO person SET id=?, first_name=?, last_name=?; SQL $sth->execute( undef, $first, $last ); $sth->finish;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Replacing DBI->do()
by karlgoethebier (Abbot) on Apr 24, 2014 at 10:32 UTC |