--
-- timespan__exists_p/1
--
create or replace function timespan__exists_p(
integer
) returns bool as $$
declare
exists_p__timespan_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 timespan_id
from timespans
where timespan_id = exists_p__timespan_id);
if v_result = 0 then
return false;
else
return true;
end if;
end;$$ language plpgsql;