From 7e73a793af79a09aa48973d06830e6fc4ef38a2e Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 4 Jul 2007 07:35:43 +0000 Subject: [PATCH] =?utf8?q?Datenbankupgrade:=20Die=20Spalte=20'storno=5Fid'?= =?utf8?q?=20in=20'ar'=20und=20'ap'=20sollte=20auch=20gef=C3=BCllt=20werde?= =?utf8?q?n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- sql/Pg-upgrade2/ar_ap_storno_id.sql | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 sql/Pg-upgrade2/ar_ap_storno_id.sql diff --git a/sql/Pg-upgrade2/ar_ap_storno_id.sql b/sql/Pg-upgrade2/ar_ap_storno_id.sql new file mode 100644 index 000000000..d4fb89051 --- /dev/null +++ b/sql/Pg-upgrade2/ar_ap_storno_id.sql @@ -0,0 +1,26 @@ +-- @tag: ar_ap_storno_id +-- @description: Füllen der Spalte 'storno_id' in den Tabellen 'ar' und 'ap' +-- @depends: ar_storno ap_storno +UPDATE ar SET storno_id = + (SELECT id + FROM ar ar2 + WHERE ar2.storno + AND ('Storno zu ' || ar2.invnumber = ar.invnumber) + AND (ar2.id < ar.id) + ORDER BY id DESC + LIMIT 1) + WHERE storno + AND (COALESCE(storno_id, 0) = 0) + AND (invnumber LIKE 'Storno zu %'); + +UPDATE ap SET storno_id = + (SELECT id + FROM ap ap2 + WHERE ap2.storno + AND ('Storno zu ' || ap2.invnumber = ap.invnumber) + AND (ap2.id < ap.id) + ORDER BY id DESC + LIMIT 1) + WHERE storno + AND (COALESCE(storno_id, 0) = 0) + AND (invnumber LIKE 'Storno zu %'); -- 2.20.1