PL Sql BULK COLLECT SQL命令没有属性结束

时间:2018-05-21 15:42:59

标签: sql oracle plsql bulk-collect

我正在尝试使用BULK COLLECT INTO但是我得到的ORA-00933 SQL命令没有正确结束。我查看了我的语法,但不确定我做错了什么。难道我做错了什么?

问题似乎与RETURNING子句有关。如果我删除了返回的子句,它编译得很好

CREATE OR REPLACE PROCEDURE CIMS.QC_PALLET_HOLD_BY_HOUR_A_REL( QC_HOLD_ID_IN IN INTEGER, HOUR_STR IN VARCHAR2, DAY_CODE IN VARCHAR2, TOP_CODE_IN IN VARCHAR2, QC_RLS_DISPOSITION_ID_IN INTEGER, SUCC_PALS_OUT OUT VARCHAR2)
IS
    l_count binary_integer;
    l_array dbms_utility.lname_array;
    curr_prod_hour varchar2(1);     
    TYPE success_hours is TABLE of pallet_hold.pallet_no%type;
    TYPE t_pallet_ids is TABLE of pallet_hold.pallet_hold_id%type;

BEGIN

    dbms_utility.comma_to_table(
        list => regexp_replace(HOUR_STR, '(^|,)','\1x'),
        tablen => l_count,
        tab => l_array
    );

        BEGIN
            forall i in l_array.FIRST .. l_array.last
            INSERT INTO PALLET_HOLD(PALLET_NO, TOP_CODE, BOTTOM_CODE, QC_HOLD_ID)
            SELECT V.PALLET_NO, V.TOP_CODE, V.BOTTOM_CODE, QC_HOLD_ID_IN
            FROM PALLET_MASTER_INQ_VIEW V
            WHERE PROD_HOUR = substr(l_array(i),2) AND SUBSTR(BOTTOM_CODE,0,5) = DAY_CODE AND TOP_CODE = TOP_CODE_IN
            AND NOT EXISTS (SELECT 1 FROM PALLET_HOLD WHERE QC_HOLD_ID = QC_HOLD_ID_IN AND PALLET_NO = V.PALLET_NO)
            RETURNING PALLET_HOLD_ID bulk collect INTO t_pallet_ids;

        EXCEPTION
            WHEN OTHERS THEN
                NULL;
        END;              

    COMMIT;

    EXCEPTION
        WHEN OTHERS THEN 
         RAISE; --raise_application_error(-20333, 'Error QC_PALLET_HOLD_BY_HOUR');

END;
/

1 个答案:

答案 0 :(得分:0)

看起来你不能按照你试图的方式使用return语句。这个问题的答案将为您提供如何完成任务的选项。

PLSQL Insert into with subquery and returning clause