The sub below is part of the calendar app I am developing. Everything works except the elsif. The elsif conditional fires off appropriately (checked it with a print statement). But the rows are not deleted. When the Add branch above it executes, the rows are deleted following an eval{} of their being moved. Even if a dozen are ok'ed they all get moved and then old row deleted but the identical code in the straight delete sequence does not throw errors or delete the rows. Anyone know why?
TIA
jg
sub approve_posts_now { my @key; foreach $key (%form_data) { if ($key =~ /^radio/ && $form_data{$key} eq "Add") { @key = split("," , $key); $sth = $dbh->prepare("INSERT INTO $calendar_table SELECT * + FROM $holding_table WHERE year=? AND month=? AND day=? AND time_start=? AND time_end=? AND tit +le=?"); $sth->bind_param(1, "$key[1]"); $sth->bind_param(2, "$key[2]"); $sth->bind_param(3, "$key[3]"); $sth->bind_param(4, "$key[4]"); $sth->bind_param(5, "$key[5]"); $sth->bind_param(6, "$key[6]"); eval {$sth->execute();}; if (!$@) { $sth = $dbh->prepare("DELETE FROM $holding_table WHERE + year=? AND month=? AND day=? AND time_start=? AND time_end=? AND + title=?"); $sth->bind_param(1, "$key[1]"); $sth->bind_param(2, "$key[2]"); $sth->bind_param(3, "$key[3]"); $sth->bind_param(4, "$key[4]"); $sth->bind_param(5, "$key[5]"); $sth->bind_param(6, "$key[6]"); $sth->execute(); } } elsif ($key =~ /^radio/ && $form_data{$key} eq "Delete") { $sth = $dbh->prepare("DELETE FROM $holding_table WHERE + year=? AND month=? AND day=? AND time_start=? AND time_end=? AND + title=?"); $sth->bind_param(1, "$key[1]"); $sth->bind_param(2, "$key[2]"); $sth->bind_param(3, "$key[3]"); $sth->bind_param(4, "$key[4]"); $sth->bind_param(5, "$key[5]"); $sth->bind_param(6, "$key[6]"); $sth->execute(); } } @success_message = h2({-align=>'center'},"Database(s) updated. Tha +nks!"); success_message(); }
_____________________________________________________
Think a race on a horse on a ball with a fish! TG

In reply to Rows fail to delete without error by jerrygarciuh

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.