changeset 1275:a356b818389a

Use gem_id for ort_id default value if exists.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 01 Feb 2017 11:23:09 +0100
parents 69042c56944d
children efa50b39c7cc
files db_schema/stammdaten_schema.sql
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/db_schema/stammdaten_schema.sql	Wed Feb 01 10:50:12 2017 +0100
+++ b/db_schema/stammdaten_schema.sql	Wed Feb 01 11:23:09 2017 +0100
@@ -18,8 +18,14 @@
     LANGUAGE plpgsql
     AS $$
     DECLARE value text;
+    DECLARE id_value text;
     BEGIN
-        value = '#'::text || lpad((NEW.id::character varying)::text, 9, '0'::text);
+        IF NEW.gem_id IS NULL THEN
+            id_value = NEW.id;
+        ELSE
+            id_value = NEW.gem_id;
+        END IF;
+        value = '#'::text || lpad(id_value, 9, '0'::text);
         IF NEW.ort_id IS NULL THEN
             NEW.ort_id = value;
         END IF;
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)