x
1
-- File: trig_i_u_syst_enums.eex.sql
2
-- Location: musebms/database/components/system/mscmp_syst_enums/ms_syst/api_views/syst_enums/trig_i_u_syst_enums.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 old.syst_defined AND new.internal_name != old.internal_name THEN
16
RAISE EXCEPTION
17
USING
18
MESSAGE = 'The requested data update included changes to fields disallowed ' ||
19
'by the business rules of the API View.',
20
DETAIL = ms_syst_priv.get_exception_details(
21
p_proc_schema => 'ms_syst'
22
,p_proc_name => 'trig_i_u_syst_enums'
23
,p_exception_name => 'invalid_api_view_call'
24
,p_errcode => 'PM008'
25
,p_param_data => to_jsonb(new)
26
,p_context_data =>
27
jsonb_build_object(
28
'tg_op', tg_op
29
,'tg_when', tg_when
30
,'tg_schema', tg_table_schema
31
,'tg_table_name', tg_table_name)),
32
ERRCODE = 'PM008',
33
SCHEMA = tg_table_schema,
34
TABLE = tg_table_name;
35
END IF;
36
37
UPDATE ms_syst_data.syst_enums SET
38
internal_name = new.internal_name
39
, display_name = new.display_name
40
, user_description = new.user_description
41
, default_user_options = new.default_user_options
42
WHERE id = new.id
43
RETURNING * INTO new;
44
45
RETURN new;
46
47
END;