0

我在光标中的选择有问题。选择在其他窗口中正常工作,但我在使用光标的过程中出现错误,为什么?我更改了表和数据库的名称,但在此过程之外选择可以

我的错误:PL/SQL:ORA-04052:ORA-00604:ORA-03106:

CREATE OR REPLACE PROCEDURE ChangeDismissDate
IS
BEGIN
    DECLARE
          v_id VARCHAR2(40);
          v_dateABC DATE;
          v_dateDismiss DATE;
        CURSOR cur IS
                select emp.EMP_NO, abc.date, emp.DISMISS_DATE  
                from  bazaabc.EmployeesDetails@BAZA_ABC abc,
                      employee_tab emp,
                      person_info_tab pin,
                      oracle_account oa
                where bhd.emp_no = emp.EMP_NO
                and   pin.PERSON_ID = emp.EMP_NO
                and   oa.USERNAME = pin.USER_ID
                and   emp.EMP_NO in (    
                select pi.PERSON_ID from tab_person pi
                where fu.active = 'TRUE'
                and   fu.IDENTITY = pi.USER_ID) AND emp.EMP_NO like '%L%'
                and nvl(abc.date,to_date('20491231','yyyymmdd')) <> nvl(emp.DISMISS_DATE,to_date('20491231','yyyymmdd'));

        BEGIN
                       OPEN cur;
                           LOOP
                                FETCH cur INTO v_id,v_dateABC,v_dateDismiss;

                                 DBMS_OUTPUT.PUT_LINE('v_id:  ' || v_id);
                                 DBMS_OUTPUT.PUT_LINE('v_dateABC:  ' || v_dateABC);
                                 DBMS_OUTPUT.PUT_LINE('v_dateDismiss:  ' ||v_dateDismiss );

                           EXIT WHEN cur%NOTFOUND;
                           END LOOP;
                       CLOSE cur;
        END;

END;
/
4

1 回答 1

0

您可以通过添加异常块来尝试解决您遇到的错误吗

CREATE OR REPLACE PROCEDURE ChangeDismissDate
IS
BEGIN
    DECLARE
          v_id VARCHAR2(40);
          v_dateABC DATE;
          v_dateDismiss DATE;
        CURSOR cur IS
                select emp.EMP_NO, abc.date, emp.DISMISS_DATE  
                from  bazaabc.EmployeesDetails@BAZA_ABC abc,
                      employee_tab emp,
                      person_info_tab pin,
                      oracle_account oa
                where bhd.emp_no = emp.EMP_NO
                and   pin.PERSON_ID = emp.EMP_NO
                and   oa.USERNAME = pin.USER_ID
                and   emp.EMP_NO in (    
                select pi.PERSON_ID from tab_person pi
                where fu.active = 'TRUE'
                and   fu.IDENTITY = pi.USER_ID) 
                AND emp.EMP_NO like '%L%'
                and nvl(abc.date,to_date('20491231','yyyymmdd')) <>  
                nvl(emp.DISMISS_DATE,to_date('20491231','yyyymmdd'));

        BEGIN
                       OPEN cur;
                           LOOP
                  FETCH cur INTO v_id,v_dateABC,v_dateDismiss;    
                  DBMS_OUTPUT.PUT_LINE('v_id:  ' || v_id);
                  DBMS_OUTPUT.PUT_LINE('v_dateABC:  ' || v_dateABC);
                  DBMS_OUTPUT.PUT_LINE('v_dateDismiss:  ' ||v_dateDismiss );

                           EXIT WHEN cur%NOTFOUND;
                           END LOOP;
                       CLOSE cur;
        END;
EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
        DBMS_OUTPUT.put_line (DBMS_UTILITY.format_error_stack);
    WHEN OTHERS
    THEN
        DBMS_OUTPUT.put_line (DBMS_UTILITY.format_error_stack);

END;
/
于 2012-11-14T12:12:32.703 回答