1

我有两个表,DUMMY_REK 和 DUMMY_REK_LOG。我已经编写了一个存储过程来执行从 DUMMY_REK 到 DUMMY_REK_LOG 的 BULK 插入。该过程运行良好,但我需要添加具有正确数据类型的 INDEX BY 子句。我在当前数据类型定义中遇到错误,因此在下面的代码中注释掉了相同的内容。有人可以建议我正确使用数据类型吗?

    CREATE OR REPLACE PROCEDURE BULK_INSERT_REK_LOG 

 as 


   TYPE tA IS TABLE OF DUMMY_REK.ID%TYPE;-- INDEX BY NUMBER;
   TYPE tB IS TABLE OF DUMMY_REK.KEYWORD%TYPE;-- INDEX BY VARCHAR2(256);
   TYPE tC IS TABLE OF DUMMY_REK.CATEGORY%TYPE;-- INDEX BY VARCHAR2(30);
   TYPE tD IS TABLE OF DUMMY_REK.LIST_NAME%TYPE;-- INDEX BY VARCHAR2(30);
   TYPE tE IS TABLE OF DUMMY_REK.EXPIRY_DATE%TYPE;-- INDEX BY DATE;
   TYPE tF IS TABLE OF DUMMY_REK.SUBMITTED_BY%TYPE;-- INDEX BY NUMBER;
   TYPE tG IS TABLE OF DUMMY_REK.SUBMITTER_COMMENTS%TYPE;-- INDEX BY VARCHAR2(4000);
   TYPE tH IS TABLE OF DUMMY_REK.SUBMITTED_TIMESTAMP%TYPE;-- INDEX BY TIMESTAMP(6);   
   TYPE tI IS TABLE OF DUMMY_REK.DECISIONED_BY%TYPE;-- INDEX BY NUMBER;
   TYPE tJ IS TABLE OF DUMMY_REK.DECISIONED_COMMENT%TYPE;-- INDEX BY VARCHAR2(4000);
   TYPE tK IS TABLE OF DUMMY_REK.DECISIONED_TIMESTAMP%TYPE;-- INDEX BY TIMESTAMP(6);
   TYPE tL IS TABLE OF DUMMY_REK.STATUS_ID%TYPE;-- INDEX BY NUMBER;   
   TYPE tM IS TABLE OF DUMMY_REK.LAST_UPDATED_TIMESTAMP%TYPE;-- INDEX BY TIMESTAMP(6);   
   TYPE tN IS TABLE OF DUMMY_REK.IS_DISABLED%TYPE;-- INDEX BY NUMBER;
   TYPE tP IS TABLE OF DUMMY_REK.KEYWORD2%TYPE;-- INDEX BY VARCHAR2(256);   
   TYPE tQ IS TABLE OF DUMMY_REK.ACCOUNT_NUMBER%TYPE;-- INDEX BY NUMBER;  
   TYPE tR IS TABLE OF DUMMY_REK.CUSTOMER_NAME%TYPE;-- INDEX BY VARCHAR2(256);   
   TYPE tS IS TABLE OF DUMMY_REK.TYPE%TYPE;-- INDEX BY NUMBER;  

    i_keyword_id tA;
    i_keyword  tB;
    i_category  tC;
    i_list_name  tD;
    i_expiry_date tE;
    i_submitted_by  tF;
    i_submitter_comments tG;
    i_submittedtimestamp tH;
    i_decisioned_by  tI;
    i_decisioned_comment  tJ;
    i_decisioned_timestamp  tK;
    i_status_id  tL;
    i_last_updated_timestamp  tM;
    i_is_disabled  tN;
    i_keyword2   tP;
    i_account_number  tQ;
    i_customer_name   tR;
    i_type  tS;

BEGIN


  SELECT * BULK COLLECT INTO i_keyword_id,i_keyword,i_category,i_list_name,i_expiry_date,i_submitted_by,i_submitter_comments,i_submittedtimestamp,i_decisioned_by,i_decisioned_comment,i_decisioned_timestamp,i_status_id,i_last_updated_timestamp,i_is_disabled,i_keyword2,i_account_number,i_customer_name,i_type FROM DUMMY_REK;
   FORALL i IN 1 .. 10 
    INSERT INTO DUMMY_REK_LOG(ID,KEYWORD_ID,KEYWORD,CATEGORY,LIST_NAME,EXPIRY_DATE,USERID,COMMENTS,LOGTIMESTAMP,WORKFLOW_ACTION_ID,WORKFLOW_REASON_ID,FROMSTATUS_ID,TOSTATUS_ID,IS_DISABLED,KEYWORD2,ACCOUNT_NUMBER,CUSTOMER_NAME,TYPE)
      VALUES(GET_NEXT_ID('DUMMY_REK_LOG'),i_keyword_id(i),i_keyword(i),i_category(i),i_list_name(i),i_expiry_date(i),i_decisioned_by(i),i_decisioned_comment(i),i_decisioned_timestamp(i),null,null,null,null,0,i_keyword2(i),i_account_number(i),i_customer_name(i),i_type(i));
commit;     

-- Exception Handling
            EXCEPTION
               WHEN OTHERS THEN
                  -- Rollback
           ROLLBACK;
     RAISE;


END BULK_INSERT_REK_LOG;
4

1 回答 1

1

正如错误所暗示的:

 CREATE OR REPLACE PROCEDURE BULK_INSERT_REK_LOG 


    DECLARE  

应该

CREATE OR REPLACE PROCEDURE BULK_INSERT_REK_LOG 
AS
于 2012-09-25T16:47:44.260 回答