aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
fn_get_calendar_sources_js
Parameters
Name
Type
Mode
p_calendar_id
integer
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.id) FROM ( SELECT s.id, s.calendar_id, c.name AS calendar_name, s.source_type, s.name, s.ics_url, s.auto_sync, s.last_sync_at, s.last_sync_status, s.last_sync_message, s.last_event_count, s.enabled FROM public.calendar_source s JOIN public.calendar c ON c.id = s.calendar_id WHERE (p_calendar_id IS NULL OR s.calendar_id = p_calendar_id) ) 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_sources_js', null::jsonb); END