June 4, 2004

Test for existing data in a db w/ perl.

Learn how to test for existing data in a database using Perl with a simple and efficient approach. Check for primary keys and handle missing data seamlessly in your scripts.

my $sth = $dbh->preparecached(q(select primarykey from table where primarykey = ?)) or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute; my ($count) = $sth->fetchrowarray; $sth->finish unless ($count) { ... }