summaryrefslogtreecommitdiff
path: root/lib/RHRD/rddb.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/RHRD/rddb.pm')
-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(), ?)};