-
Notifications
You must be signed in to change notification settings - Fork 1
/
02_functions.sql
88 lines (59 loc) · 2.31 KB
/
02_functions.sql
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
--
-- Name: refresh_mv_batiments(); Type: FUNCTION; Schema: pompiers; Owner: <user>
--
CREATE FUNCTION pompiers.refresh_mv_batiments() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
REFRESH MATERIALIZED VIEW pompiers.pom_vgeo_batiments;
RETURN NULL;
END;
$$;
ALTER FUNCTION pompiers.refresh_mv_batiments() OWNER TO "<user>";
--
-- Name: set_geom_emplacement_echelle(); Type: FUNCTION; Schema: pompiers; Owner: <user>
--
CREATE FUNCTION pompiers.set_geom_emplacement_echelle() RETURNS trigger
LANGUAGE plpgsql
AS $$BEGIN
INSERT INTO pompiers.pom_edit_emplacements (fk_type_id,remarque,orientation,geom,fk_gestionnaire_id)
VALUES (1,new.remarque,270-(degrees(ST_Azimuth(ST_AsText(ST_EndPoint(ST_LineMerge(new.geom))),ST_AsText(ST_StartPoint(ST_LineMerge(new.geom)))))),st_centroid(ST_OffsetCurve(ST_LineMerge(new.geom),5)),new.fk_gestionnaire_id);
RETURN new;
END;$$;
ALTER FUNCTION pompiers.set_geom_emplacement_echelle() OWNER TO "<user>";
--
-- Name: set_path_absolu_document(); Type: FUNCTION; Schema: pompiers; Owner: <user>
--
CREATE FUNCTION pompiers.set_path_absolu_document() RETURNS trigger
LANGUAGE plpgsql
AS $$BEGIN
SELECT INTO new.document
CASE
WHEN new.document IS NOT NULL THEN replace(new.document, 'T:', '\\struve\SDIS') -- Spécifique Nyon
ELSE NULL
END;
RETURN new;
END;$$;
ALTER FUNCTION pompiers.set_path_absolu_document() OWNER TO "<user>";
--
-- Name: FUNCTION set_path_absolu_document(); Type: COMMENT; Schema: pompiers; Owner: <user>
--
COMMENT ON FUNCTION pompiers.set_path_absolu_document() IS 'Convertit le chemin relatif en chemin absolu pour l''attribut document';
--
-- Name: set_path_absolu_photo(); Type: FUNCTION; Schema: pompiers; Owner: <user>
--
CREATE FUNCTION pompiers.set_path_absolu_photo() RETURNS trigger
LANGUAGE plpgsql
AS $$BEGIN
SELECT INTO new.photo
CASE
WHEN new.photo IS NOT NULL THEN replace(new.photo, 'T:', '\\struve\SDIS') -- Spécifique Nyon
ELSE NULL
END;
RETURN new;
END;$$;
ALTER FUNCTION pompiers.set_path_absolu_photo() OWNER TO "<user>";
--
-- Name: FUNCTION set_path_absolu_photo(); Type: COMMENT; Schema: pompiers; Owner: <user>
--
COMMENT ON FUNCTION pompiers.set_path_absolu_photo() IS 'Convertit le chemin relatif en chemin absolu pour l''attribut photo';