ALTER FUNCTION "DBA"."get_makslist"( in a_nimi char(50))
RETURNS INTEGER
BEGIN
  declare ll_return integer;
  if length(a_nimi)>0 then
    select first maksnr into ll_return from ls_makslist where Trim(maksukood)=a_nimi;
    if ll_return is null then
      select first maksnr into ll_return from ls_makslist where Trim(nimi)=a_nimi;
    end if
  end if;
  if ll_return is null then
    set ll_return=0
  end if;
  return ll_return;
END