-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathupdate1.1.0to1.2.1.sql
More file actions
60 lines (55 loc) · 1.82 KB
/
Copy pathupdate1.1.0to1.2.1.sql
File metadata and controls
60 lines (55 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
CREATE OR REPLACE FUNCTION ref_nomenclatures.get_nomenclature_label_by_cdnom_mnemonique(
mytype character varying,
mycdnomenclature character varying)
RETURNS character varying AS
$BODY$
--Function which return the label from the id_nomenclature and the language
DECLARE
labelfield character varying;
thelabel character varying;
BEGIN
EXECUTE format( ' SELECT label_default
FROM ref_nomenclatures.t_nomenclatures n
WHERE cd_nomenclature = $1 AND id_type = ref_nomenclatures.get_id_nomenclature_type($2)' )INTO thelabel USING mycdnomenclature, mytype;
return thelabel;
END;
$BODY$
LANGUAGE plpgsql IMMUTABLE
COST 100;
CREATE OR REPLACE FUNCTION ref_nomenclatures.get_nomenclature_label_by_cdnom_mnemonique_and_language(
mytype character varying,
mycdnomenclature character varying,
mylanguage character varying)
RETURNS character varying AS
$BODY$
--Function which return the label from the cd_nomenclature, the code_type and the language
DECLARE
labelfield character varying;
thelabel character varying;
BEGIN
labelfield = 'label_'||mylanguage;
EXECUTE format( ' SELECT %s
FROM ref_nomenclatures.t_nomenclatures n
WHERE cd_nomenclature = $1 AND id_type = ref_nomenclatures.get_id_nomenclature_type($2)',labelfield )INTO thelabel USING mycdnomenclature, mytype;
return thelabel;
END;
$BODY$
LANGUAGE plpgsql IMMUTABLE
COST 100;
CREATE OR REPLACE FUNCTION ref_nomenclatures.get_nomenclature_label(
myidnomenclature integer DEFAULT NULL
)
RETURNS character varying AS
$BODY$
--Function which return the label from the id_nomenclature
DECLARE
thelabel character varying;
BEGIN
SELECT INTO thelabel label_default
FROM ref_nomenclatures.t_nomenclatures n
WHERE id_nomenclature = myidnomenclature;
return thelabel;
END;
$BODY$
LANGUAGE plpgsql IMMUTABLE
COST 100;