summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-05-06 15:54:02 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2016-05-06 15:54:02 (GMT)
commit813c9f6de35dfbf40d9f59eb77d9dae7ea1161fa (patch)
tree805604087287fb1161b692231414ba0354efd10d /lib
parent9dd27d91403cc988ef0e4d31db6808799cb0d700 (diff)
generated schedules now get updated if they already exist
Diffstat (limited to 'lib')
-rwxr-xr-xlib/RHRD/rddb.pm16
1 files changed, 14 insertions, 2 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(), ?)};