我有两个表,DUMMY_REK和DUMMY_REK_LOG。我编写了一个存储过程来从DUMMY_REK执行BULK插入到DUMMY_REK_LOG。该过程运行正常,但我需要添加具有正确数据类型的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;
答案 0 :(得分:1)
由于错误暗示:
CREATE OR REPLACE PROCEDURE BULK_INSERT_REK_LOG
DECLARE
应该是
CREATE OR REPLACE PROCEDURE BULK_INSERT_REK_LOG
AS