Skip to content
Snippets Groups Projects
Commit 4793df77 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- add SQL statements to handle purged AIPs

parent 1ca35ce6
No related branches found
No related tags found
No related merge requests found
...@@ -154,11 +154,24 @@ CREATE TABLE deleted ( ...@@ -154,11 +154,24 @@ CREATE TABLE deleted (
aip_id INTEGER NOT NULL REFERENCES aip (id), aip_id INTEGER NOT NULL REFERENCES aip (id),
state TEXT NOT NULL, state TEXT NOT NULL,
reason TEXT NOT NULL, reason TEXT NOT NULL,
note TEXT,
date DATE, date DATE,
authorized_by TEXT NOT NULL, authorized_by TEXT NOT NULL,
PRIMARY KEY(id AUTOINCREMENT) PRIMARY KEY(id AUTOINCREMENT)
); );
SQL_CREATE6 SQL_CREATE6
my $sql8=<<"SQL_CREATE8";
CREATE TABLE purged (
id INTEGER,
aip_id INTEGER NOT NULL REFERENCES aip (id),
state TEXT NOT NULL,
reason TEXT,
note TEXT,
date DATE,
authorized_by TEXT NOT NULL,
PRIMARY KEY(id AUTOINCREMENT)
);
SQL_CREATE8
my $sql7=<<"SQL_CREATE7"; my $sql7=<<"SQL_CREATE7";
CREATE TABLE transferaip ( CREATE TABLE transferaip (
id INTEGER, id INTEGER,
...@@ -176,6 +189,7 @@ SQL_CREATE7 ...@@ -176,6 +189,7 @@ SQL_CREATE7
my $sth5 = $dbh->prepare($sql5); $sth5->execute() or die "sql problem detected", $dbh->errstr; my $sth5 = $dbh->prepare($sql5); $sth5->execute() or die "sql problem detected", $dbh->errstr;
my $sth6 = $dbh->prepare($sql6); $sth6->execute() or die "sql problem detected", $dbh->errstr; my $sth6 = $dbh->prepare($sql6); $sth6->execute() or die "sql problem detected", $dbh->errstr;
my $sth7 = $dbh->prepare($sql7); $sth7->execute() or die "sql problem detected", $dbh->errstr; my $sth7 = $dbh->prepare($sql7); $sth7->execute() or die "sql problem detected", $dbh->errstr;
my $sth8 = $dbh->prepare($sql8); $sth8->execute() or die "sql problem detected", $dbh->errstr;
return 1; return 1;
} }
...@@ -213,10 +227,16 @@ SQL_LOCAT_PLAN ...@@ -213,10 +227,16 @@ SQL_LOCAT_PLAN
); );
SQL_DC_PLAN SQL_DC_PLAN
my $sql_deleted_plan=<<"SQL_DELETE_PLAN"; my $sql_deleted_plan=<<"SQL_DELETE_PLAN";
INSERT INTO deleted (aip_id, state, reason, date, authorized_by) VALUES ( INSERT INTO deleted (aip_id, state, reason, note, date, authorized_by) VALUES (
(SELECT id FROM aip WHERE aip.ie_id=\$1 AND aip.version=\$2), \$3, \$4, \$5, \$6 (SELECT id FROM aip WHERE aip.ie_id=\$1 AND aip.version=\$2), \$3, \$4, \$5, \$6, \$7
); );
SQL_DELETE_PLAN SQL_DELETE_PLAN
my $sql_purged_plan=<<"SQL_PURGED_PLAN";
INSERT INTO purged (aip_id, state, reason, note, date, authorized_by) VALUES (
(SELECT id FROM aip WHERE aip.ie_id=\$1 AND aip.version=\$2), \$3, \$4, \$5, \$6, \$7
);
SQL_PURGED_PLAN
my $sth_aip_plan = $dbh->prepare($sql_aip_plan); my $sth_aip_plan = $dbh->prepare($sql_aip_plan);
my $sth_ie_plan = $dbh->prepare($sql_ie_plan); my $sth_ie_plan = $dbh->prepare($sql_ie_plan);
...@@ -224,6 +244,7 @@ SQL_DELETE_PLAN ...@@ -224,6 +244,7 @@ SQL_DELETE_PLAN
my $sth_locat_plan = $dbh->prepare($sql_locat_plan); my $sth_locat_plan = $dbh->prepare($sql_locat_plan);
my $sth_dc_plan = $dbh->prepare($sql_dc_plan); my $sth_dc_plan = $dbh->prepare($sql_dc_plan);
my $sth_deleted_plan = $dbh->prepare($sql_deleted_plan); my $sth_deleted_plan = $dbh->prepare($sql_deleted_plan);
my $sth_purged_plan = $dbh->prepare($sql_purged_plan);
my $plans; my $plans;
$plans->{aip} = $sth_aip_plan; $plans->{aip} = $sth_aip_plan;
$plans->{ie} = $sth_ie_plan; $plans->{ie} = $sth_ie_plan;
...@@ -231,6 +252,7 @@ SQL_DELETE_PLAN ...@@ -231,6 +252,7 @@ SQL_DELETE_PLAN
$plans->{locat} = $sth_locat_plan; $plans->{locat} = $sth_locat_plan;
$plans->{dc} = $sth_dc_plan; $plans->{dc} = $sth_dc_plan;
$plans->{deleted} = $sth_deleted_plan; $plans->{deleted} = $sth_deleted_plan;
$plans->{purged} = $sth_purged_plan;
return $plans; return $plans;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment