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