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; }


___________
Eric Hodges

In reply to Re: duplicate key check isn't, why not? by eric256
in thread duplicate key check isn't, why not? by hesco

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.