Thank you, I finally found the culprit, it is really DBI (mysql).

This workaround made my program working:

The beginning of my subroutine:

sub write_status($$$$) { my $host = $_[0]; my $app = $_[1]; my $status = $_[2]; my $version = $_[3]; my $result = $dbh->begin_work(); if (! defined $result) { $result = -1; } if ($result < 0) { print STDERR "\n" . $0 . ": CHYBA: " . $dbh->errstr . "\n"; return ISHN_ERR_INTERNAL; }
I needed to add this dummy UPDATE to somehow reset something (without it only few or none rows were updated):
my $statement = q{UPDATE results SET status = ?, verze = 'N/A' WHERE host = ? AND app = ?;}; $result = $dbh->do($statement, undef, $status, $host, $app); if (! defined $result) { $result = -1; } if ($result <= 0) { print STDERR "\n" . $0 . ": CHYBA: " . $dbh->errstr . "\n"; $dbh->rollback(); return ISHN_ERR_INTERNAL; }
This is the rest of my subroutine:
$statement = q{UPDATE results SET status = ?, verze = ? WHERE host = ? AND app = ?;}; $result = $dbh->do($statement, undef, $status, $version, $host, $app +); if (! defined $result) { $result = -1; } if ($result <= 0) { print STDERR "\n" . $0 . ": CHYBA: " . $dbh->errstr . "\n"; $dbh->rollback(); return ISHN_ERR_INTERNAL; } $statement = q{INSERT INTO history (host, app, status, verze) VALUES (?, ?, ?, ?);}; $result = $dbh->do($statement, undef, $host, $app, $status, $version +); if (! defined $result) { $result = -1; } if ($result <= 0) { print STDERR "\n" . $0 . ": CHYBA: " . $dbh->errstr . "\n"; $dbh->rollback(); return ISHN_ERR_INTERNAL; } $result = $dbh->commit(); if (! defined $result) { $result = -1; } if ($result < 0) { print STDERR "\n" . $0 . ": CHYBA: " . $dbh->errstr . "\n"; $dbh->rollback(); return ISHN_ERR_INTERNAL; } else { return ISHN_OK; } }

In reply to Re^2: Variable scope & subroutines by Nyyr
in thread Variable scope & subroutines by Nyyr

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.