I use only one sub to run simple SQL:
sub runSQL {
my $sql = shift;
if ($sql =~ /^select/i) {
my $sth = $dbh->prepare($sql);
if (!$sth) {
die "Error:" . $dbh->errstr . " :: $sql\n";
}
if (!$sth->execute) {
die "Error:" . $sth->errstr . " :: $sql\n";
}
my @ret;
while (my $ref = $sth->fetchrow_hashref()) {
push @ret, $ref;
}
$sth->finish();
return \@ret;
}
elsif ($sql =~ /^(insert|update|delete)/i) {
if (!($dbh->do($sql))) {
die "Error:" . $dbh->errstr . " :::: $sql\n";
}
}
}
and I get a reference to an array of hashes that holds values of SELECTS..
He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
Chady | http://chady.net/