I see nothing wrong with your SQL as written, though I will say this again:

Use placeholders. They will prevent certain nasty kinds of errors from cropping up; one thing that might cause problems with your code as written is that IF there any quotes or other zany things in your data, that will result in the SQL string not being well-formed; if you use placeholders, these issues will be dealt with automatically. All this adds up to : use placeholders

OK, with that out of the way ... check to see whether you've issued a commit to the database (this will have no effect if you're using a DB without commit and rollback, like vanilla MySQL), as sutch recommended. If the statements execute without error but nothing happens in the database, that's one place to look. Also, as thabenskta mentioned, you should always return the value of $dbh->errstr when a call to the database fails. So put those in, they'll help with debugging!

Now, as to the method: whatdo is good for one-off things, but it forces you to prepare each statement each time through the loop. That's inefficient: prepare once, execute many times! So go with the normal prepare, bind, execute cycle:

my $sth1 = $db->prepare(q{ UPDATE trees SET department = ? WHERE sport = ? AND round = ? }) or die "Can't prepare first statement: ". $dbh->errstr() . + "\n"; # and so with $sth2 and $sth3 # execution time for my $i (1..13) { # I'd suggest reworking this data structure too, but # I'll work with what you have # smaller sermon : initialize the variables that are # expected to change on each step through the loop # with my *** inside the loop *** # that way, you get a fresh copy of the variable each time # through without potentially having old values intrude my $team = $teams{"team$i"}; my $score = $scores{"score$i'}; $sth1->execute ($team, $sport, $i) or die "Execution of first update failed: ". $dbh->errstr() ." +\n"; $sth2->execute( #blah blah... }

HTH.

Philosophy can be made out of anything. Or less -- Jerry A. Fodor


In reply to Re: Re: Re: allowed by arturo
in thread more and more dbi issues by Anonymous Monk

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.