aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
fn_get_calendars_js
Parameters
Name
Type
Mode
p_type
text
IN (DEFAULT NULL)
Definition
DECLARE v_result json; v_state text; v_message text; v_detail text; v_hint text; v_context text; BEGIN SELECT json_agg(t ORDER BY t.name, t.id) FROM ( SELECT c.id, c.code, c.name, c.calendar_type, c.color, c.is_public_holiday, c.remark, c.enabled, (SELECT count(*)::int FROM public.calendar_event e WHERE e.calendar_id = c.id) AS event_count FROM public.calendar c WHERE (p_type IS NULL OR c.calendar_type = p_type) ) t INTO v_result; RETURN coalesce(v_result, '[]'::json); EXCEPTION WHEN OTHERS THEN GET STACKED DIAGNOSTICS v_state = RETURNED_SQLSTATE, v_message = MESSAGE_TEXT, v_detail = PG_EXCEPTION_DETAIL, v_hint = PG_EXCEPTION_HINT, v_context = PG_EXCEPTION_CONTEXT; RETURN fn_handle_error(v_state, v_message, v_detail, v_hint, v_context, 'public.fn_get_calendars_js', null::jsonb); END