[Lada-commits] [PATCH] Use gem_id for ort_id default value if exists

Wald Commits scm-commit at wald.intevation.org
Wed Feb 1 11:23:15 CET 2017


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1485944589 -3600
# Node ID a356b818389ae4bb747d3cba0d79ba076bc263ad
# Parent  69042c56944d4fed91ea4fe463eb9a4954af8675
Use gem_id for ort_id default value if exists.

diff -r 69042c56944d -r a356b818389a db_schema/stammdaten_schema.sql
--- 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;


More information about the Lada-commits mailing list