-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_configuration_bool.sql
47 lines (42 loc) · 1.21 KB
/
get_configuration_bool.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
-- FUNCTION: code_src.get_configuration_bool(text, text, text, boolean)
-- DROP FUNCTION code_src.get_configuration_bool(text, text, text, boolean);
CREATE OR REPLACE FUNCTION code_src.get_configuration_bool(
v_category text,
v_type text,
v_name text,
v_default_value boolean DEFAULT false)
RETURNS boolean
LANGUAGE 'plpgsql'
COST 100
VOLATILE SECURITY DEFINER
AS $BODY$
DECLARE
retval boolean;
thevalue text;
BEGIN
/*
Summary:
Get boolean setting from configuration table
Testing:
select get_configuration_bool('anchorTO', 'ANCHORTO', 'sync_with_oracle')
*/
retval = false;
SELECT get_configuration($1, $2, $3) INTO thevalue;
RAISE NOTICE '%', thevalue;
IF thevalue IS NULL AND $4 IS NOT NULL THEN
RETURN $4;
END IF;
RETURN upper(thevalue) = 'T'
OR upper(thevalue) = 'TRUE'
OR thevalue = '1'
OR upper(thevalue) = 'Y'
OR upper(thevalue) = 'YES'
OR upper(thevalue) = 'ON';
EXCEPTION
WHEN OTHERS THEN
RAISE NOTICE '%', SQLERRM;
RETURN $4;
END;
$BODY$;
ALTER FUNCTION code_src.get_configuration_bool(text, text, text, boolean) OWNER TO network;
GRANT EXECUTE ON FUNCTION code_src.get_configuration_bool(text, text, text, boolean) TO anchorto_run