Revision ba9f2104
Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt
sql/Pg-upgrade2/warehouse.pl | ||
---|---|---|
46 | 46 |
my $warehouse = $main::form->{import_warehouse} ne '' ? $main::form->{import_warehouse} : "Transfer"; |
47 | 47 |
my $bin = $main::form->{bin_default} ne '' ? $main::form->{bin_default} : "1"; |
48 | 48 |
|
49 |
$warehouse = $dbh->quote($warehouse); |
|
50 |
$bin = $dbh->quote($bin); |
|
49 | 51 |
|
50 | 52 |
my $migration_code = <<EOF |
51 | 53 |
|
52 | 54 |
-- Adjust warehouse |
53 |
INSERT INTO warehouse (description) VALUES ('$warehouse');
|
|
55 |
INSERT INTO warehouse (description, sortkey, invalid) VALUES ($warehouse, 1, FALSE);
|
|
54 | 56 |
|
55 | 57 |
UPDATE tmp_parts SET bin = NULL WHERE bin = ''; |
56 | 58 |
|
57 | 59 |
-- Restore old onhand |
58 | 60 |
INSERT INTO bin |
59 | 61 |
(warehouse_id, description) |
60 |
(SELECT DISTINCT warehouse.id, COALESCE(bin, '$bin')
|
|
62 |
(SELECT DISTINCT warehouse.id, COALESCE(bin, $bin)
|
|
61 | 63 |
FROM warehouse, tmp_parts |
62 |
WHERE warehouse.description='$warehouse');
|
|
64 |
WHERE warehouse.description=$warehouse);
|
|
63 | 65 |
INSERT INTO inventory |
64 | 66 |
(warehouse_id, parts_id, bin_id, qty, employee_id, trans_id, trans_type_id) |
65 | 67 |
(SELECT warehouse.id, tmp_parts.id, bin.id, onhand, (SELECT id FROM employee LIMIT 1), nextval('id'), transfer_type.id |
66 | 68 |
FROM transfer_type, warehouse, tmp_parts, bin |
67 |
WHERE warehouse.description = '$warehouse'
|
|
68 |
AND COALESCE(bin, '$bin') = bin.description
|
|
69 |
WHERE warehouse.description = $warehouse
|
|
70 |
AND COALESCE(bin, $bin) = bin.description
|
|
69 | 71 |
AND transfer_type.description = 'stock'); |
70 | 72 |
EOF |
71 | 73 |
; |
Auch abrufbar als: Unified diff
Datenbankupgrade für Einführung der Lagerverwaltung: 1. SQL-sicheres Quoten der Eingaben; 2. Beim Anlegen des Lagers alle Tabellenfelder füllen, weil ansonsten später das Lager nicht verfügbar erscheint. Fix für Bug 834.