CREATE FUNCTION "DBA"."pa_gl_tasu"( in a_kuup date,in a_tas_s integer,in a_paryldnr integer ) 
returns integer
begin
  declare li_return integer;
  if exists(select 1 from gl_pa_tasu where gl_pa_tasu.tas_s = a_tas_s and gl_pa_tasu.paryldnr = a_paryldnr and gl_pa_tasu.a_apaev <= day(a_kuup) and gl_pa_tasu.a_lpaev >= day(a_kuup)) then
    set li_return = 1
  else
    set li_return = 0
  end if;
  return(li_return)
end