Mercurial > lada > lada-server
comparison db_schema/stammdaten_schema.sql @ 1179:612107caf961
Declared variable in db function set_ort_id.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 16 Nov 2016 17:02:22 +0100 |
parents | 33dc7dc6b7bc |
children | 1bc8ab13e1f7 |
comparison
equal
deleted
inserted
replaced
1178:047a27138af6 | 1179:612107caf961 |
---|---|
15 SET search_path = stammdaten, pg_catalog; | 15 SET search_path = stammdaten, pg_catalog; |
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 BEGIN | 21 BEGIN |
21 value = '#'::text || lpad((NEW.id::character varying)::text, 9, '0'::text); | 22 value = '#'::text || lpad((NEW.id::character varying)::text, 9, '0'::text); |
22 IF NEW.ort_id IS NULL THEN | 23 IF NEW.ort_id IS NULL THEN |
23 NEW.ort_id = value; | 24 NEW.ort_id = value; |
24 END IF; | 25 END IF; |