my $sth = $dbh->prepare("UPDATE $table SET upc=$upc WHERE item_id=$ite +m_id;"); die "DBH Error:" . $dbh->errstr . "\n" if (!$sth); if (!$sth->execute) { # Oops! $item_id doesn't exist in $table so add it. my $sth = $dbh->prepare("INSERT INTO $table (item_id, upc) VALUES( +$item_id, $upc);"); die "DBH Error:" . $dbh->errstr . "\n" if (!$sth); die "STH Error:" . $sth->errstr . "\n" if (!$sth->execute); }
In reply to Database Update or Insert by Mr. Muskrat
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |