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

- added table creation

parent ccbf0f0d
No related branches found
No related tags found
No related merge requests found
......@@ -140,12 +140,24 @@ SQL_CREATE4
PRIMARY KEY(id AUTOINCREMENT)
);
SQL_CREATE5
my $sql6=<<"SQL_CREATE6";
CREATE TABLE deleted (
id INTEGER,
aip_id INTEGER NOT NULL REFERENCES aip (id),
state TEXT NOT NULL,
reason TEXT NOT NULL,
date DATE,
authorized_by TEXT NOT NULL,
PRIMARY KEY(id AUTOINCREMENT)
);
SQL_CREATE6
my $sth1 = $dbh->prepare($sql1); $sth1->execute() or die "sql problem detected", $dbh->errstr;
my $sth2 = $dbh->prepare($sql2); $sth2->execute() or die "sql problem detected", $dbh->errstr;
my $sth3 = $dbh->prepare($sql3); $sth3->execute() or die "sql problem detected", $dbh->errstr;
my $sth4 = $dbh->prepare($sql4); $sth4->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;
return 1;
}
......@@ -177,22 +189,30 @@ SQL_FILE_PLAN
sourcedatafile.name=\$3), \$4, \$5
);
SQL_LOCAT_PLAN
my $sql_dc_pan=<<"SQL_DC_PLAN";
my $sql_dc_plan=<<"SQL_DC_PLAN";
INSERT INTO dc (aip_id, element, value) VALUES (
(SELECT id FROM aip WHERE aip.ie_id=\$1 AND aip.version=\$2), \$3, \$4
);
SQL_DC_PLAN
my $sql_deleted_plan=<<"SQL_DELETE_PLAN";
INSERT INTO deleted (aip_id, state, reason, date, authorized_by) VALUES (
(SELECT id FROM aip WHERE aip.ie_id=\$1 AND aip.version=\$2), \$3, \$4, \$5, \$6
);
SQL_DELETE_PLAN
my $sth_aip_plan = $dbh->prepare($sql_aip_plan);
my $sth_ie_plan = $dbh->prepare($sql_ie_plan);
my $sth_file_plan = $dbh->prepare($sql_file_plan);
my $sth_locat_plan = $dbh->prepare($sql_locat_plan);
my $sth_dc_plan = $dbh->prepare($sql_dc_pan);
my $sth_dc_plan = $dbh->prepare($sql_dc_plan);
my $sth_deleted_plan = $dbh->prepare($sql_deleted_plan);
my $plans;
$plans->{aip} = $sth_aip_plan;
$plans->{ie} = $sth_ie_plan;
$plans->{file} = $sth_file_plan;
$plans->{locat} = $sth_locat_plan;
$plans->{dc} = $sth_dc_plan;
$plans->{deleted} = $sth_deleted_plan;
return $plans;
}
......@@ -218,6 +238,8 @@ SQL_DC_PLAN
# $ret{"dcrecords"} = \@dcrecords;
###############################################################################
sub write_addsql ($dbh, $plans, $refhash) {
use Data::Printer;
p( $refhash);
my $iefile = basename($refhash->{"filename"});
my ($ieid,$ieversion);
if ($iefile =~ m/^V(\d+)-(IE\d*)\.xml$/) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment