-
Notifications
You must be signed in to change notification settings - Fork 1
/
10_process_upsert.sql
51 lines (38 loc) · 1.15 KB
/
10_process_upsert.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
/*
PEUPLEMENT DES TABLES PAR TRIGGERS
-----
Simulation d'un update pour déclencher le trigger
*/
BEGIN TRANSACTION
;
TRUNCATE pr_vigienature.t_releve RESTART IDENTITY CASCADE
;
UPDATE src_vn_json.forms_json
SET
item = item
WHERE
(site, id) IN (SELECT
site
, id
FROM
src_vn_json.forms_json f
WHERE
f.item #>> '{protocol,protocol_name}' LIKE 'S_OC%'
AND item ->> 'id_form_universal' NOT LIKE '0')
;
END TRANSACTION;
BEGIN TRANSACTION;
ALTER TABLE src_vn_json.observations_json DISABLE TRIGGER fct_tri_c_upsert_vn_observation_to_geonature;
UPDATE src_vn_json.observations_json
SET
item = item
WHERE
observations_json.id_form_universal IN
(SELECT
bdd_source_id_universal
FROM
pr_vigienature.t_releve
)
;
ALTER TABLE src_vn_json.observations_json DISABLE TRIGGER fct_tri_c_upsert_vn_observation_to_geonature;
END TRANSACTION;