Mercurial > lada > lada-server
comparison 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 |
comparison
equal
deleted
inserted
replaced
1274:69042c56944d | 1275:a356b818389a |
---|---|
16 | 16 |
17 CREATE FUNCTION set_ort_id() RETURNS trigger | 17 CREATE FUNCTION set_ort_id() RETURNS trigger |
18 LANGUAGE plpgsql | 18 LANGUAGE plpgsql |
19 AS $$ | 19 AS $$ |
20 DECLARE value text; | 20 DECLARE value text; |
21 DECLARE id_value text; | |
21 BEGIN | 22 BEGIN |
22 value = '#'::text || lpad((NEW.id::character varying)::text, 9, '0'::text); | 23 IF NEW.gem_id IS NULL THEN |
24 id_value = NEW.id; | |
25 ELSE | |
26 id_value = NEW.gem_id; | |
27 END IF; | |
28 value = '#'::text || lpad(id_value, 9, '0'::text); | |
23 IF NEW.ort_id IS NULL THEN | 29 IF NEW.ort_id IS NULL THEN |
24 NEW.ort_id = value; | 30 NEW.ort_id = value; |
25 END IF; | 31 END IF; |
26 IF NEW.langtext IS NULL THEN | 32 IF NEW.langtext IS NULL THEN |
27 NEW.langtext = value; | 33 NEW.langtext = value; |