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