Mercurial > lada > lada-server
diff db_schema/stammdaten_schema.sql @ 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 | cb88ab44c2be |
children | 5549c214e816 |
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;