in reply to duplicate key check isn't, why not?
First think I do with code I don't understand is reformat it ;) So just in case its usefull to you i've included the reformatted code. All I really did was use slices so the arrays are readable and then edited the error messages to look similar. Once done it was fairly obvious that the error was on line #14 and that its using $mlg_addr_id which you distinctly specified shouldn't be defined. BTW i don't you sequnce of duplicate checks at all, it might make since but its hard to tell from this small sample of code.
$sth_mlg_addr_duplicate_check->execute(@fields[17,18,19,20,21,22,23]) or warn "While checking for duplicate mailing address " . "$fields[17]; $fields[19] $fields[20]: " . $dbh->errstr; ($mlg_addr_id) = $sth_mlg_addr_duplicate_check->fetchrow_array(); my $mlg_id; if(!defined($mlg_addr_id) && length($fields[20]) == 2) { #insert $sth_insert_mlg_addr->execute(@fields[17,18,19,20,21,22,23]) or warn "While inserting new mailing address " . "|$fields[17]|; |$fields[19]| |$fields[20]|, with id |$m +lg_addr_id|: " . $dbh->errstr; #check duplicate $sth_mlg_addr_duplicate_check->execute(@fields[17,18,19,20,21,22,23 +]) or warn "While checking for duplicate mailing address " . "|$fields[17]|; |$fields[19]| |$fields[20]|: " . $dbh->errstr; ($mlg_addr_id) = $sth_mlg_addr_duplicate_check->fetchrow_array(); $mlg_id = $mlg_addr_id; } else { $mlg_id = $mlg_addr_id; }
|
|---|