SQL doesn't care. If the name, address, and street don't match any existing record, then the update will not happen. Of course, for proper error checking my suggestion may not be helpful, but i still thought i should put this thought in your mind anyway. ;)my $sth = $dbh->prepare(" UPDATE many_address SET name=NULL, date_loaded=NULL WHERE name=? AND number=? AND street=? "); while (<RA>) { my ($name,$add,$street) = split(/\|/,$_); chomp($street); $sth->execute($name,$add,$street); }
P.S. Get out of the habit of using NULL now, before it is too late! Use another field named 'status' if you are wanting to 'delete' a record without removing it from the table.
UPDATE:
Well, there is a way to find out if a row was updated or
not, but you have to use do() instead, thus giving
up your placeholders. From the docs:
UPDATE x 2:$rows_affected = $dbh->do("UPDATE your_table SET foo = foo + 1");
... while (<RA>) { my ($name,$add,$street) = split(/\|/,$_); chomp($street); my $ret = $sth->execute($name,$add,$street); print "no update for $name\n" if $ret == 0; }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to (jeffa) Re: DBI multiple prepares
by jeffa
in thread DBI multiple prepares
by vivekvp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |