SQL ora-01086 : 保存点未建立或无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21138597/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 00:44:40  来源:igfitidea点击:

ora-01086 : save point was not established or invalid

sqloracleplsqloracle11gsavepoints

提问by Bilgin K?l??

Ora-01086 : save point was not established or invalid. KRD_UPD_BORCTAHSILATYAP_SP this SP throws errors . When I test this loop below, I get the error: ora-01086

Ora-01086 : 保存点未建立或无效。KRD_UPD_BORCTAHSILATYAP_SP 此 SP 引发错误。当我在下面测试此循环时,出现错误:ora-01086

Normally it works without calling an external sp, I test it with an inline error and I rolledback to the save point. What am I missing ?

通常它在不调用外部 sp 的情况下工作,我使用内联错误对其进行测试,然后回滚到保存点。我错过了什么?

FOR rec IN (...records.....
               )
   LOOP
      SAVEPOINT odemeIslemiBaslangic;
      BEGIN


         CASE rec.prosedur_ad
            WHEN 'KRD' THEN

               KRD_UPD_BORCTAHSILATYAP_SP(rec.musterino, rec.urundegeri, rec.taksitno, v_MuhasebeReferans, v_IslemReferans, v_Tarih);
               IF v_MuhasebeReferans IS NOT NULL THEN
                  v_SonucKd  := 10;
                  v_Aciklama := 'Ba?ar?l? i?lem';
               ELSE
                  v_SonucKd  := 9;
                  v_Aciklama := 'Bor? bulunamad?';
               END IF;

         END CASE;
         cll_ins_tahsilatislem_sp(p_odemeno        => rec.odemeno,
                                  p_islemtarihi    => v_Tarih,
                                  p_musterino      => rec.musterino,
                                  p_urundeger      => rec.urundegeri,
                                  p_islemref       => v_IslemReferans,
                                  p_muhasebesubekd => rec.sube_kd,
                                  p_muhaseberef    => v_MuhasebeReferans,
                                  p_aciklama       => v_Aciklama,
                                  p_sonuc          => v_SonucKd,
                                  p_kayityapan     => v_KayitYapan,
                                  p_kayittrxkod    => v_KayitTrxKod);
         UPDATE cll_gecikmisbankaalacak u
            SET u.sonuc_kd = v_SonucKd
          WHERE u.odemeno = rec.odemeno
            AND u.kayit_drm = 'A';
      EXCEPTION
         WHEN OTHERS THEN
            ROLLBACK TO SAVEPOINT odemeIslemiBaslangic;
            v_SonucKd  := 1;
            v_Aciklama := '??lem Hata: ' || substr(SQLERRM, 1, 400);
            cll_ins_tahsilatislem_sp(p_odemeno        => rec.odemeno,
                                     p_islemtarihi    => v_Tarih,
                                     p_musterino      => rec.musterino,
                                     p_urundeger      => rec.urundegeri,
                                     p_islemref       => v_IslemReferans,
                                     p_muhasebesubekd => rec.sube_kd,
                                     p_muhaseberef    => v_MuhasebeReferans,
                                     p_aciklama       => v_Aciklama,
                                     p_sonuc          => v_SonucKd,
                                     p_kayityapan     => v_KayitYapan,
                                     p_kayittrxkod    => v_KayitTrxKod);
            UPDATE cll_gecikmisbankaalacak u
               SET u.sonuc_kd = v_SonucKd
             WHERE u.odemeno = rec.odemeno
               AND u.kayit_drm = 'A';
      END;

   END LOOP;

回答by Alex Poole

Your comment suggests that the procedure you are calling, KRD_UPD_BORCTAHSILATYAP_SP, is rolling back the whole transaction, i.e. issuing a simple ROLLBACK.

您的评论表明您正在调用的过程KRD_UPD_BORCTAHSILATYAP_SP正在回滚整个事务,即发出一个简单的ROLLBACK.

From the documentation for ROLLBACK:

文档中ROLLBACK

Using ROLLBACKwithout the TO SAVEPOINTclause performs the following operations:

  • Ends the transaction
  • Undoes all changes in the current transaction
  • Erases all savepoints in the transaction
  • Releases any transaction locks

ROLLBACK不带TO SAVEPOINT子句使用执行以下操作:

  • 结束交易
  • 撤消当前事务中的所有更改
  • 清除事务中的所有保存点
  • 释放任何事务锁

The savepoint you established in your calling block is therefore being erased, so you can no longer roll back to that.

因此,您在调用块中建立的保存点将被删除,因此您无法再回滚到该保存点。