x
1
-- File: generate_comments_table_column.eex.sql
2
-- Location: musebms/database/all/ms_syst_priv/functions/generate_comments_table_column.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
DECLARE
14
var_resolved_description text;
15
var_resolved_general_usage text;
16
var_resolved_func_type text;
17
var_resolved_life_cycle text;
18
var_resolved_constraint text;
19
var_resolved_direct_usage text;
20
21
var_comment text;
22
23
BEGIN
24
25
var_resolved_description := p_comments_config.description;
26
27
var_resolved_general_usage :=
28
E'**General Usage**\n\n' ||
29
p_comments_config.general_usage;
30
31
var_resolved_func_type :=
32
E'**Functional Type Reference**\n\n' ||
33
CASE
34
WHEN p_comments_config.func_type_text IS NOT NULL THEN
35
p_comments_config.func_type_text
36
WHEN p_comments_config.func_type_name IS NOT NULL THEN
37
'This column references the Functional Types Enumeration \n`' ||
38
p_comments_config.func_type_name ||
39
E'` defined in table `ms_syst_data.syst_enums`\nand its ' ||
40
E'associated tables.\n\n' ||
41
E'Specific available Functional Type values are documented ' ||
42
E'in the records of\nthose tables.'
43
END;
44
45
var_resolved_life_cycle :=
46
E'**Life-Cycle State Reference**\n\n' ||
47
CASE
48
WHEN p_comments_config.state_text IS NOT NULL THEN
49
p_comments_config.state_text
50
WHEN p_comments_config.state_name IS NOT NULL THEN
51
'This column references the State Enumeration \n`' ||
52
p_comments_config.state_name ||
53
E'` defined in table `ms_syst_data.syst_enums`\nand' ||
54
E' its associated tables.\n\nSpecific available ' ||
55
E'State values are documented in the records of ' ||
56
E'those tables.'
57
END;
58
59
var_resolved_constraint :=
60
E'**Constraint Reference**\n\n' ||
61
p_comments_config.constraints;
62
63
var_resolved_direct_usage :=
64
E'**Direct Usage**\n\n' ||
65
p_comments_config.direct_usage;
66
67
var_comment :=
68
CASE
69
WHEN
70
var_resolved_description IS NOT NULL
71
OR var_resolved_general_usage IS NOT NULL
72
OR var_resolved_func_type IS NOT NULL
73
OR var_resolved_life_cycle IS NOT NULL
74
OR var_resolved_constraint IS NOT NULL
75
OR var_resolved_direct_usage IS NOT NULL
76
THEN
77
coalesce( var_resolved_description || E'\n\n', '' ) ||
78
coalesce( var_resolved_general_usage || E'\n\n', '' ) ||
79
coalesce( var_resolved_func_type || E'\n\n', '' ) ||
80
coalesce( var_resolved_life_cycle || E'\n\n', '' ) ||
81
coalesce( var_resolved_constraint || E'\n\n', '' ) ||
82
coalesce( var_resolved_direct_usage || E'\n\n', '' )
83
ELSE
84
E'This table column is not yet documented.\n\n'
85
END;
86
87
EXECUTE format( 'COMMENT ON COLUMN %1$I.%2$I.%3$I IS %4$L;',
88
p_table_schema,
89
p_table_name,
90
p_comments_config.column_name,
91
var_comment );
92
93
END;