Thank you, I finally found the culprit, it is really DBI (mysql).
This workaround made my program working:
The beginning of my subroutine:
I needed to add this dummy UPDATE to somehow reset something (without it only few or none rows were updated):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; }
This is the rest of my subroutine: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; }
$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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |