ALTER FUNCTION "DBA"."get_ea_tr_level"(in a_komb_id integer, in a_level smallint)
returns smallint
begin
  declare li_tr_level smallint;
  case a_level
  when 1 then
    select ea_komb.tr_level1 into li_tr_level from ea_komb where "id" = a_komb_id
  when 2 then
    select ea_komb.tr_level2 into li_tr_level from ea_komb where "id" = a_komb_id
  when 3 then
    select ea_komb.tr_level3 into li_tr_level from ea_komb where "id" = a_komb_id
  when 4 then
    select ea_komb.tr_level4 into li_tr_level from ea_komb where "id" = a_komb_id
  when 5 then
    select ea_komb.tr_level5 into li_tr_level from ea_komb where "id" = a_komb_id
  when 6 then
    select ea_komb.tr_level6 into li_tr_level from ea_komb where "id" = a_komb_id
  when 7 then
    select ea_komb.tr_level7 into li_tr_level from ea_komb where "id" = a_komb_id
  when 100 then
    select ea_komb.tr_kok_jaot into li_tr_level from ea_komb where "id" = a_komb_id
  else
    set li_tr_level=0
  end case
  ;
  if li_tr_level is null then
    set li_tr_level=0
  end if;
  return li_tr_level
end