x
1
-- File: trig_i_u_syst_identities.eex.sql
2
-- Location: musebms/database/components/system/mscmp_syst_authn/ms_syst/api_views/syst_identities/trig_i_u_syst_identities.eex.sql
3
-- Project: Muse Systems Business Management System
4
--
5
-- Copyright © Lima Buttgereit Holdings LLC d/b/a Muse Systems
6
-- This file may include content copyrighted and licensed from third parties.
7
--
8
-- See the LICENSE file in the project root for license terms and conditions.
9
-- See the NOTICE file in the project root for copyright ownership information.
10
--
11
-- muse.information@musesystems.com :: https://muse.systems
12
13
BEGIN
14
15
IF
16
new.access_account_id != old.access_account_id OR
17
new.identity_type_id != old.identity_type_id OR
18
new.account_identifier != old.account_identifier OR
19
new.validates_identity_id != old.validates_identity_id
20
THEN
21
RAISE EXCEPTION
22
USING
23
MESSAGE = 'The requested data update included changes to fields disallowed ' ||
24
'by the business rules of the API View.',
25
DETAIL = ms_syst_priv.get_exception_details(
26
p_proc_schema => 'ms_syst'
27
,p_proc_name => 'trig_i_u_syst_identities'
28
,p_exception_name => 'invalid_api_view_call'
29
,p_errcode => 'PM008'
30
,p_param_data => jsonb_build_object('new', new, 'old', old)
31
,p_context_data =>
32
jsonb_build_object(
33
'tg_op', tg_op
34
,'tg_when', tg_when
35
,'tg_schema', tg_table_schema
36
,'tg_table_name', tg_table_name)),
37
ERRCODE = 'PM008',
38
SCHEMA = tg_table_schema,
39
TABLE = tg_table_name;
40
END IF;
41
42
UPDATE ms_syst_data.syst_identities
43
SET
44
validated = new.validated
45
, validation_requested = new.validation_requested
46
, identity_expires = new.identity_expires
47
, external_name = new.external_name
48
WHERE id = new.id
49
RETURNING * INTO new;
50
51
RETURN new;
52
53
END;