CREATE PROCEDURE "DBA"."ea_korrigeeri_koik"( in a_par char(20),in a_id1 integer, in a_s1 char(20) )
BEGIN
  case a_par
    when 'kor_meetmed' then
      update "ea_kanne" left outer join "gl_selectall" on "ea_kanne"."id"="gl_selectall"."id1" and "ea_kanne"."aasta"="gl_selectall"."id2"
        set "ea_kanne"."nr"=a_id1 where "gl_selectall"."id1" is not null
    when 'kor_kuluobjektid' then
      update "ea_kanne" left outer join "gl_selectall" on "ea_kanne"."id"="gl_selectall"."id1" and "ea_kanne"."aasta"="gl_selectall"."id2"
        set "ea_kanne"."kulnr"=a_id1 where "gl_selectall"."id1" is not null
    when 'kor_tegevusalad' then
      update "ea_kanne" left outer join "gl_selectall" on "ea_kanne"."id"="gl_selectall"."id1" and "ea_kanne"."aasta"="gl_selectall"."id2"
        set "ea_kanne"."talnr"=a_id1 where "gl_selectall"."id1" is not null
    when 'kor_kululiigid' then
      update "ea_kanne" left outer join "gl_selectall" on "ea_kanne"."id"="gl_selectall"."id1" and "ea_kanne"."aasta"="gl_selectall"."id2"
        set "ea_kanne"."artnr"=a_id1 where "gl_selectall"."id1" is not null
    when 'kor_tululiigid' then
      update "ea_kanne" left outer join "gl_selectall" on "ea_kanne"."id"="gl_selectall"."id1" and "ea_kanne"."aasta"="gl_selectall"."id2"
        set "ea_kanne"."tulnr"=a_id1 where "gl_selectall"."id1" is not null
    when 'kor_projektid' then
      update "ea_kanne" left outer join "gl_selectall" on "ea_kanne"."id"="gl_selectall"."id1" and "ea_kanne"."aasta"="gl_selectall"."id2"
        set "ea_kanne"."objectnr"=a_id1 where "gl_selectall"."id1" is not null
    when 'kor_osakonnad' then
      update "ea_kanne" left outer join "gl_selectall" on "ea_kanne"."id"="gl_selectall"."id1" and "ea_kanne"."aasta"="gl_selectall"."id2"
        set "ea_kanne"."osaknr"=a_id1 where "gl_selectall"."id1" is not null
    when 'kor_subjektid' then
      update "ea_kanne" left outer join "gl_selectall" on "ea_kanne"."id"="gl_selectall"."id1" and "ea_kanne"."aasta"="gl_selectall"."id2"
        set "ea_kanne"."subjectnr"=a_id1 where "gl_selectall"."id1" is not null
    when 'kor_tegevussuunad' then
      update "ea_kanne" left outer join "gl_selectall" on "ea_kanne"."id"="gl_selectall"."id1" and "ea_kanne"."aasta"="gl_selectall"."id2"
        set "ea_kanne"."suundnr"=a_id1 where "gl_selectall"."id1" is not null
    when 'kor_taotlused' then
      update "ea_kanne" left outer join "gl_selectall" on "ea_kanne"."id"="gl_selectall"."id1" and "ea_kanne"."aasta"="gl_selectall"."id2"
        set "ea_kanne"."taotnr"=a_id1 where "gl_selectall"."id1" is not null
  end case;
END