DECLARE
-- Local variables here
ID VARCHAR2(20) := ''9020071025101010'';
TEMPID VARCHAR2(20) := '''';
--定義VARCHAR2的數組以及大小
TYPE ARRSYVAR IS VARRAY(2) OF VARCHAR2(30);
ARRAYPARA ARRSYVAR; --數組變量
BEGIN
-- Test statements here
ARRAYPARA := ARRSYVAR(''1234567'', ''2345678''); --數組初始化
FOR K IN 1 .. 2 LOOP
-- calculate pi with 100 terms
TEMPID := ID || TO_CHAR(K);
INSERT INTO TI_ORDER_CD (ORDERID,MSISDN,SWITCHID,PRIORITY,STATE,CREATE_TIME)
VALUES(TEMPID,ARRAYPARA(K),''PHS'',''0'',''K'',SYSDATE);
INSERT INTO TI_ORDER_SERV_CD(ORDERID, SERVID, SERVCODE) VALUES(TEMPID, ''0'', ''CG001'');
INSERT INTO TI_ORDER_VAR_CD(ORDERID, PARACODE, PARAVALUE) VALUES(TEMPID, ''X009'', ARRAYPARA(K)); --數組取值
END LOOP;
END;