chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Distance sailed shows in voyage plan now
[ypp-sc-tools.main.git]
/
yarrg
/
db-idempotent-populate
diff --git
a/yarrg/db-idempotent-populate
b/yarrg/db-idempotent-populate
index 96df020f842de9ab78e0e59035f7ab5122313db3..b44d45dd25cc7d63c435059c521bfc0b84a36800 100755
(executable)
--- a/
yarrg/db-idempotent-populate
+++ b/
yarrg/db-idempotent-populate
@@
-1,5
+1,8
@@
#!/usr/bin/perl -w
#
#!/usr/bin/perl -w
#
+# Normally run from
+# update-master-info
+#
# usage: ./db-idempotent-populate <Oceanname>
# creates or updates OCEAN-Oceanname.db
# from master-master.txt
# usage: ./db-idempotent-populate <Oceanname>
# creates or updates OCEAN-Oceanname.db
# from master-master.txt
@@
-103,12
+106,28
@@
$dbh->commit;
#---------- commodity list ----------
{
#---------- commodity list ----------
{
- my $sth= $dbh->prepare(<<'END')
- INSERT OR IGNORE INTO commods (commodname) VALUES (?);
+ my $insert= $dbh->prepare(<<'END')
+ INSERT OR IGNORE INTO commods
+ (unitmass,
+ unitvolume,
+ commodname)
+ VALUES (?,?,?);
+END
+ ;
+ my $update= $dbh->prepare(<<'END')
+ UPDATE commods
+ SET unitmass = ?,
+ unitvolume = ?
+ WHERE commodname = ?
END
;
foreach my $commod (sort keys %commods) {
END
;
foreach my $commod (sort keys %commods) {
- $sth->execute($commod);
+ my $c= $commods{$commod};
+ die "no mass for $commod" unless defined $c->{Mass};
+ die "no colume for $commod" unless defined $c->{Volume};
+ my @qa= ($c->{Mass}, $c->{Volume}, $commod);
+ $insert->execute(@qa);
+ $update->execute(@qa);
}
$dbh->commit;
}
}
$dbh->commit;
}