X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fdb-idempotent-populate;h=80ded466aefeb4ab89899fae5218dd7da2537e72;hb=e05f0567ea23491da8e48f892a3337f37139628f;hp=96df020f842de9ab78e0e59035f7ab5122313db3;hpb=847492a8eebac261fb3ffa5e97391b486a73d336;p=ypp-sc-tools.db-live.git diff --git a/yarrg/db-idempotent-populate b/yarrg/db-idempotent-populate index 96df020..80ded46 100755 --- a/yarrg/db-idempotent-populate +++ b/yarrg/db-idempotent-populate @@ -103,12 +103,26 @@ $dbh->commit; #---------- 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) { - $sth->execute($commod); + my $c= $commods{$commod}; + my @qa= ($c->{Mass}, $c->{Volume}, $commod); + $insert->execute(@qa); + $update->execute(@qa); } $dbh->commit; }