ALTER FUNCTION "DBA"."get_tundi_nadalas"( in a_lepnr integer ) 
returns numeric(15,3)
begin
  declare ldc_tunde numeric(15,3);
  declare ldc_nt numeric(10,3);
  declare li_pnk integer;
  select ntlist.pnk,ntlist.nt into li_pnk,ldc_nt from pa_leping left outer join ntlist on pa_leping.ntt = ntlist.ntt where pa_leping.lepnr = a_lepnr;
  case li_pnk
  when 14 then
    set ldc_tunde = Round(ldc_nt*5,3)
  when 13 then
    set ldc_tunde = Round(ldc_nt,3)
  when 1 then
    set ldc_tunde = Round(ldc_nt*60/254,3)
  when 12 then
    set ldc_tunde = Round(ldc_nt*5/254,3)
  else
    set ldc_tunde = 0
  end case;
  return(ldc_tunde)
end