CREATE FUNCTION "DBA"."pa_gl_peat"( in a_kuup date ) 
returns integer
begin
  declare li_return integer;
  if exists(select 1 from gl_pa_tgraaf where gl_pa_tgraaf.akuup<=a_kuup and gl_pa_tgraaf.lkuup>=a_kuup) then
    set li_return = 1
  else
    set li_return = 0
  end if;
  return(li_return)
end