aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
fn_get_calendar_events_js
Parameters
Name
Type
Mode
p_start
date
IN
p_end
date
IN
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.start_date, t.calendar_id, t.id) FROM ( SELECT e.id, e.calendar_id, c.name AS calendar_name, c.calendar_type, c.is_public_holiday, e.name, e.start_date, coalesce(e.end_date, e.start_date) AS end_date, e.all_day, e.start_time, e.end_time, coalesce(e.color, c.color) AS color, e.remark FROM public.calendar_event e JOIN public.calendar c ON c.id = e.calendar_id WHERE c.enabled AND e.enabled AND e.start_date <= p_end AND coalesce(e.end_date, e.start_date) >= p_start AND (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_calendar_events_js', null::jsonb); END