Sql 当光标%未找到问题时退出

Sql 当光标%未找到问题时退出,sql,oracle,plsql,oracle10g,Sql,Oracle,Plsql,Oracle10g,大家好,我有一个pl/sql语句,它应该通过游标从一个表到另一个表获取数据,但有些字段是空的,我想这就是它退出该行的原因 exit when cursor%not found; 我已经在谷歌上搜索过了,我看到了使用finter-fetch语句的建议,但当您有两个游标时,似乎就是这样,但在我的情况下,我只有一个游标。请找个人帮我调整一下这个查询 CREATE OR REPLACE procedure TBAADM.MIGR_EIT AS CURSOR cur_eit IS SELECT ent

大家好,我有一个pl/sql语句,它应该通过游标从一个表到另一个表获取数据,但有些字段是空的,我想这就是它退出该行的原因

exit when cursor%not found;
我已经在谷歌上搜索过了,我看到了使用finter-fetch语句的建议,但当您有两个游标时,似乎就是这样,但在我的情况下,我只有一个游标。请找个人帮我调整一下这个查询

CREATE OR REPLACE procedure TBAADM.MIGR_EIT
AS
CURSOR cur_eit  IS SELECT entity_id, nrml_accrued_amount_cr,nrml_accrued_amount_dr,   nrml_booked_amount_cr, nrml_booked_amount_dr, nrml_interest_amount_cr,
nrml_interest_amount_dr,
next_int_run_date_cr ,next_int_run_date_dr ,interest_calc_upto_date_cr,   interest_calc_upto_date_dr,xfer_min_bal
,xfer_min_bal_date, booked_upto_date_cr,booked_upto_date_dr FROM TBAADM.eit_temp  ;
tempeit1  TBAADM.EIT%ROWTYPE;
number_of_rows_updated number;
BEGIN
number_of_rows_updated:=0;

update tbaadm.eit_temp set entity_id=(select gam.acid from tbaadm.gam where gam.foracid=eit_temp.act_num);

OPEN cur_eit;

LOOP
FETCH cur_eit INTO  tempeit1.entity_id,tempeit1.nrml_accrued_amount_cr,tempeit1.nrml_accrued_amount_dr,tempeit1    .nrml_booked_amount_cr,tempeit1.nrml_booked_amount_dr,
tempeit1.nrml_interest_amount_cr, tempeit1.nrml_interest_amount_dr,
tempeit1.next_int_run_date_cr ,tempeit1.next_int_run_date_dr  ,tempeit1.interest_calc_upto_date_cr,  tempeit1.interest_calc_upto_date_dr,tempeit1.xfer_min_bal
,tempeit1.xfer_min_bal_date, tempeit1.booked_upto_date_cr,tempeit1.booked_upto_date_dr;
exit when cur_eit%notfound;

自从Oracle 8以来,不再需要显式游标(IMHO advisible)。我将重写您的代码,以便在
中使用隐式光标来。。。循环

CREATE OR REPLACE PROCEDURE tbaadm.migr_eit
AS
  number_of_rows_updated   NUMBER;
BEGIN
  number_of_rows_updated := 0;

  UPDATE tbaadm.eit_temp
     SET entity_id =
           (SELECT gam.acid
              FROM tbaadm.gam
             WHERE gam.foracid = eit_temp.act_num);

  FOR tempeit1 IN (SELECT entity_id
                         ,nrml_accrued_amount_cr
                         ,nrml_accrued_amount_dr
                         ,nrml_booked_amount_cr
                         ,nrml_booked_amount_dr
                         ,nrml_interest_amount_cr
                         ,nrml_interest_amount_dr
                         ,next_int_run_date_cr
                         ,next_int_run_date_dr
                         ,interest_calc_upto_date_cr
                         ,interest_calc_upto_date_dr
                         ,xfer_min_bal
                         ,xfer_min_bal_date
                         ,booked_upto_date_cr
                         ,booked_upto_date_dr
                     FROM tbaadm.eit_temp)
  LOOP
    /* do what ever you need to do with 
      tempeit1.entity_id,tempeit1.nrml_accrued_amount_cr,tempeit1.nrml_accrued_amount_dr,tempeit1    .nrml_booked_amount_cr,tempeit1.nrml_booked_amount_dr,
      tempeit1.nrml_interest_amount_cr, tempeit1.nrml_interest_amount_dr,
      tempeit1.next_int_run_date_cr ,tempeit1.next_int_run_date_dr  ,tempeit1.interest_calc_upto_date_cr,  tempeit1.interest_calc_upto_date_dr,tempeit1.xfer_min_bal
      ,tempeit1.xfer_min_bal_date, tempeit1.booked_upto_date_cr,tempeit1.booked_upto_date_dr;
    */
    NULL; -- do something useful
  END LOOP;

任何人谁能帮我?加入“dbms_output.put_line('tempeit1.entity_id=>”| | tempeit1.entity_id);”在exit when语句之后查看失败的位置。是否可以简单地放弃光标的打开,简单地重写要在查询中完成的转换?此外,如果您使用的是SQL Developer,您也可以对其进行调试。您的问题没有足够的信息,任何人都无法真正帮助您。您关于“某些字段是空的,我认为这就是它退出该行的原因”的猜测肯定是错误的--
当cur\u eit%NOTFOUND时退出
不会被获取的记录中的空值所愚弄--但是这里的任何人都无法判断问题的实质。