Revision 7e73a793
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
sql/Pg-upgrade2/ar_ap_storno_id.sql | ||
---|---|---|
1 |
-- @tag: ar_ap_storno_id |
|
2 |
-- @description: Füllen der Spalte 'storno_id' in den Tabellen 'ar' und 'ap' |
|
3 |
-- @depends: ar_storno ap_storno |
|
4 |
UPDATE ar SET storno_id = |
|
5 |
(SELECT id |
|
6 |
FROM ar ar2 |
|
7 |
WHERE ar2.storno |
|
8 |
AND ('Storno zu ' || ar2.invnumber = ar.invnumber) |
|
9 |
AND (ar2.id < ar.id) |
|
10 |
ORDER BY id DESC |
|
11 |
LIMIT 1) |
|
12 |
WHERE storno |
|
13 |
AND (COALESCE(storno_id, 0) = 0) |
|
14 |
AND (invnumber LIKE 'Storno zu %'); |
|
15 |
|
|
16 |
UPDATE ap SET storno_id = |
|
17 |
(SELECT id |
|
18 |
FROM ap ap2 |
|
19 |
WHERE ap2.storno |
|
20 |
AND ('Storno zu ' || ap2.invnumber = ap.invnumber) |
|
21 |
AND (ap2.id < ap.id) |
|
22 |
ORDER BY id DESC |
|
23 |
LIMIT 1) |
|
24 |
WHERE storno |
|
25 |
AND (COALESCE(storno_id, 0) = 0) |
|
26 |
AND (invnumber LIKE 'Storno zu %'); |
Auch abrufbar als: Unified diff
Datenbankupgrade: Die Spalte 'storno_id' in 'ar' und 'ap' sollte auch gefüllt werden.