为什么我没有找到数据发现错误?

时间:2014-03-30 09:16:33

标签: oracle oracle10g

到一个void这个错误我只是变量,所以如果有记录返回,那么做其他 但我仍然得到这个错误,任何人都可以帮我摆脱这个? 多数民众赞成在第一次查询,但没有第35行的查询 我可以使用sql%rowcount吗?

declare 
    cust_id bmh.info.CUSTOMER_ID@prod%type; --get the id of sp number 
    num number; -- count of records in rated_rejectes_calls_cursor
    num1 number; -- count of records in rated_rejectes_calls_cursor


    V_CUST_INFO_CUSTOMER_ID FI_MASAAD.FEB_PRD_14_VIEW.CUST_INFO_CUSTOMER_ID@rtx%type;
    V_INITIAL_START_TIME_TIMESTAMP FI_MASAAD.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
    select count(*) into num from bmh.info@prod where dn_num=rated_rejectes_calls_rec.S_P_NUM;
    if num <>0 then 
    select CUSTOMER_ID into cust_id from bmh.info@prod where dn_num=rated_rejectes_calls_rec.S_P_NUM;

    dbms_output.put_line('SP number,  '||rated_rejectes_calls_rec.S_P_NUM||'  ID is,  '||cust_id||' and call start time, '||rated_rejectes_calls_rec.CALL_START_TIME);


    select count(*) into  num1
    from FI_MASAAD.MAR_14_VIEW@rtx a
    where  CUST_INFO_CUSTOMER_ID =cust_id
    and INITIAL_START_TIME_TIMESTAMP=rated_rejectes_calls_rec.CALL_START_TIME;

    elsif num1 <> 0  then
    select CUST_INFO_CUSTOMER_ID, INITIAL_START_TIME_TIMESTAMP into V_CUST_INFO_CUSTOMER_ID,V_INITIAL_START_TIME_TIMESTAMP 
    from FI_MASAAD.MAR_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;

    elsif num1 =0 then
    dbms_output.put_line('tickets not found, '||rated_rejectes_calls_rec.S_P_NUM);

    elsif num=0 then
    dbms_output.put_line('SP number ID not found, '||rated_rejectes_calls_rec.S_P_NUM);
    end if;
    end loop;
    end;

提前谢谢大家

1 个答案:

答案 0 :(得分:0)

使用嵌套的开始块..

 BEGIN
   --statements
    BEGIN
        select CUSTOMER_ID into cust_id from bmh.info@prod where dn_num=rated_rejectes_calls_rec.S_P_NUM;
    EXCEPTION WHEN NO_DATA_FOUND THEN
       --Handle Exception for No Data here
    END;
EXCEPTION WHEN OTHERS THEN
 -- Final Exceptions go here
END;
/