-- -- acs_event__instances_exist_p/1 -- create or replace function acs_event__instances_exist_p( integer ) returns bool as $$ declare instances_exist_p__recurrence_id alias for $1; v_result integer; begin -- Only need to check if any rows exist. select count(*) into v_result from dual where exists (select recurrence_id from acs_events where recurrence_id = instances_exist_p__recurrence_id); if v_result = 0 then return false; else return true; end if; end;$$ language plpgsql;