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