summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/RHRD/rddb.pm16
-rwxr-xr-xutils/rhrd-schedules2
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index df514d7..1172acd 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -966,7 +966,7 @@ sub list_logs
return @logs;
}
-sub create_schedule_log
+sub create_or_update_schedule_log
{
my $ctx = shift;
my $year = shift;
@@ -980,7 +980,19 @@ sub create_schedule_log
return (undef, $status, $errorstring);
}
if($log_exists) {
- return (undef, 'ERROR', "Log with name '" . $logname . "' already exists")
+ my $sql = qq{delete from LOGS where NAME = ?;};
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute($logname)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ $sth->finish();
+
+ (my $cnt, $status, $errorstring) = drop_log_table($ctx, $logname);
+ unless (defined $cnt) {
+ return (undef, $status, $errorstring);
+ }
}
my $sql = qq{insert into LOGS (NAME, LOG_EXISTS, TYPE, DESCRIPTION, ORIGIN_USER, ORIGIN_DATETIME, LINK_DATETIME, SERVICE) values (?, 'N', 0, ?, ?, NOW(), NOW(), ?)};
diff --git a/utils/rhrd-schedules b/utils/rhrd-schedules
index 7a83458..cee3f3d 100755
--- a/utils/rhrd-schedules
+++ b/utils/rhrd-schedules
@@ -78,7 +78,7 @@ sub generate
$show->{'START_TIME'} = ($start->hour * 3600) + ($start->minute * 60) + $start->second;
push @shows, $show;
}
- my ($result, $status, $errorstring) = RHRD::rddb::create_schedule_log($ctx, $year, $month, $day, @shows);
+ my ($result, $status, $errorstring) = RHRD::rddb::create_or_update_schedule_log($ctx, $year, $month, $day, @shows);
unless(defined $result) {
print "$status: $errorstring\n";
return 1;