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