【问题标题】:work around keyword by calling same procedure?通过调用相同的过程来解决关键字?
【发布时间】:2014-03-24 07:56:16
【问题描述】:

由于 continue 关键字不起作用,因为以下原因,我试图通过调用相同的过程并将记录中的下一个值传递给它来解决这个问题 那是正确的方法吗?

ORA-06550:第 1 行,第 26 列:PLS-00201:标识符“CONTINUE”必须是 声明 ORA-06550:第 1 行,第 26 列:PL/SQL:语句被忽略

declare 
cust_id info.CUSTOMER_ID@prod%type;
V_CUST_INFO_CUSTOMER_ID FEB_PRD_14_VIEW.CUST_INFO_CUSTOMER_ID@rtx%type;
V_INITIAL_START_TIME_TIMESTAMP FEB_PRD_14_VIEW.INITIAL_START_TIME_TIMESTAMP@rtx%type;

cursor rated_rejectes_calls_cursor is 
select S_P_NUM,CALL_START_TIME
from fi_sdine.rejected_calls_87@prod 
where UPPER (STATUS)='RATED';

begin
for rated_rejectes_calls_rec in rated_rejectes_calls_cursor
loop
if (rated_rejectes_calls_rec.S_P_NUM is not null) then

begin

select CUSTOMER_ID into cust_id from bmh.info@prod where dn_num=rated_rejectes_calls_rec.S_P_NUM;

if (V_CUST_INFO_CUSTOMER_ID is null ) then
select CUST_INFO_CUSTOMER_ID, INITIAL_START_TIME_TIMESTAMP into V_CUST_INFO_CUSTOMER_ID,V_INITIAL_START_TIME_TIMESTAMP 
from FI_MASAAD.FEB_PRD_14_VIEW@rtx a
where  CUST_INFO_CUSTOMER_ID =cust_id
and INITIAL_START_TIME_TIMESTAMP=rated_rejectes_calls_rec.CALL_START_TIME 
group by CUST_INFO_CUSTOMER_ID,INITIAL_START_TIME_TIMESTAMP;

DBMS_OUTPUT.PUT_LINE('null NOT Found '||V_CUST_INFO_CUSTOMER_ID);

end if;

dbms_output.put_line('The customer ID for S_P_NUM '||rated_rejectes_calls_rec.S_P_NUM||' is '||cust_id|| ' and the call start time is  '||rated_rejectes_calls_rec.CALL_START_TIME||' has been found' );
dbms_output.put_line('The customer ID'||V_CUST_INFO_CUSTOMER_ID||' and call start is '||V_INITIAL_START_TIME_TIMESTAMP);

exception 

when no_data_found then
dbms_output.put_line('The Customer ID NOT FOUND FOR S_P_NUM '|| rated_rejectes_calls_rec.S_P_NUM);
 --contunie;
-- recall procedure and pass the next value to same procedure ?
exec check_rejected_CDRs(rated_rejectes_calls_rec.nextval);

end;
end if;
end loop;
end;
end check_rejected_CDRs;

【问题讨论】:

  • 我在他的代码中没有看到CONTINUE这个词,我不明白你的问题。
  • 代码更新它...因为我用召回程序替换它

标签: oracle oracle10g


【解决方案1】:

您可能将异常处理程序放在错误的位置。 我认为您正在努力实现这一目标....

declare

cust_id info.CUSTOMER_ID@prod%type;
V_CUST_INFO_CUSTOMER_ID FEB_PRD_14_VIEW.CUST_INFO_CUSTOMER_ID@rtx%type;
V_INITIAL_START_TIME_TIMESTAMP FEB_PRD_14_VIEW.INITIAL_START_TIME_TIMESTAMP@rtx%type;

cursor rated_rejectes_calls_cursor is 
select S_P_NUM,CALL_START_TIME
from fi_sdine.rejected_calls_87@prod 
where UPPER (STATUS)='RATED';

begin
for rated_rejectes_calls_rec in rated_rejectes_calls_cursor
loop
    if (rated_rejectes_calls_rec.S_P_NUM is not null) then

    begin

         select CUSTOMER_ID into cust_id from bmh.info@prod where dn_num=rated_rejectes_calls_rec.S_P_NUM;

         if (V_CUST_INFO_CUSTOMER_ID is null ) then

            BEGIN 



            select CUST_INFO_CUSTOMER_ID, INITIAL_START_TIME_TIMESTAMP into V_CUST_INFO_CUSTOMER_ID,V_INITIAL_START_TIME_TIMESTAMP
            from FI_MASAAD.FEB_PRD_14_VIEW@rtx a
            where  CUST_INFO_CUSTOMER_ID=cust_id
            and INITIAL_START_TIME_TIMESTAMP=rated_rejectes_calls_rec.CALL_START_TIME
            group by CUST_INFO_CUSTOMER_ID,INITIAL_START_TIME_TIMESTAMP;

            DBMS_OUTPUT.PUT_LINE('null NOT Found '||V_CUST_INFO_CUSTOMER_ID);   

例外 当 no_data_found 然后 dbms_output.put_line('未找到 S_P_NUM 的客户 ID '||rated_rejectes_calls_rec.S_P_NUM); 执行 check_rejected_CDRs(rated_rejectes_calls_rec.nextval); 结束;

         end if;

         dbms_output.put_line('The customer ID for S_P_NUM '||rated_rejectes_calls_rec.S_P_NUM||' is '||cust_id|| ' and the call start time is  '||rated_rejectes_calls_rec.CALL_START_TIME||' has been found' );
         dbms_output.put_line('The customer ID'||V_CUST_INFO_CUSTOMER_ID||' and call start is '||V_INITIAL_START_TIME_TIMESTAMP);

    end;

    end if;

end loop;

end;

end check_rejected_CDRs;

【讨论】:

  • 异常块应该是最后一个代码块我相信这段代码不会工作......但我测试过它给出了一个异常
  • 异常块不必是最后一个代码块。 PL/SQL 中的常见做法是使用本地化异常处理来捕获代码中的特定错误。通过这样做 - 代码可以记录错误 - 处理异常并继续处理。当然,欢迎您在代码末尾添加另一个错误处理程序。
  • 感谢您提供有用的信息,但此代码引发以下异常 ORA-06550:第 35 行,第 17 列:PLS-00103:在预期以下情况之一时遇到符号“WHEN”:
  • 这是一个错字 - 已编辑但 - 您需要输入... 没有找到数据时例外
  • 然后我们回到第一个问题,我收到错误 [错误] PLS-00103 (39: 26):PLS-00103:在预期以下情况之一时遇到符号“CHECK_REJECTED_CDRS”:想想这个方式不适用 := 。 ( @ % ; 符号 ":=" 被替换为 "CHECK_REJECTED_CDRS" 以继续。
猜你喜欢
  • 1970-01-01
  • 2019-07-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多