2016-05-09 33 views
-1

カーソルを使用してデータベース表の1つにデータを設定しているデータベースに以下のプロシージャを作成しました。プロシージャを実行中にエラーが発生しました:プロシージャの実行中にプロシージャにエラーが発生しました

ORA-00911: invalid character ORA-06512: at "SOURCE_PACNET.IPSERVICE_TEST_FINAL", line 43 ORA-06512: at line 1 00911. 00000 - "invalid character" *Cause: identifiers may not start with any ASCII character other than letters and numbers. $#_ are also allowed after the first character. Identifiers enclosed by doublequotes may contain any character other than a doublequote. Alternative quotes (q'#...#') cannot use spaces, tabs, or carriage returns as delimiters. For all other contexts, consult the SQL Language Reference Manual.

私のコードで何が間違っているかを確認してください。

CREATE OR REPLACE PROCEDURE TEST_FINAL AS 
    CURSOR Cur_TieredPricing_PCT IS 
      SELECT * 
      FROM IPSERVICE_46PRCT_NO4CASES_TST 
     ORDER BY BILLPROFILEID, TELSTRA_SERVICE_ID; 

    V_ODD_EVN   NUMBER; 
    V_ID_CNT    NUMBER; 
    V_IN     VARCHAR(4) := 'In'; 
    V_OUT    VARCHAR(4) := 'Out'; 
    insertstatement  VARCHAR2(5000); 
    insertstatement_1 VARCHAR2(5000); 
    insertstatement_2 VARCHAR2(5000); 

    Isp_TR_var   VARCHAR2(100) := 'PACNET_U_IPT_ISP_32483'; 

    V_CAL_TYPE   IPSERVICE_46PRCT_NO4CASES.CALCULATION__TYPE%TYPE; 
BEGIN 
    FOR Cur_TieredPricing_PCT_REC IN Cur_TieredPricing_PCT LOOP 
     --- select count from tier_id field 
     SELECT DISTINCT REGEXP_COUNT Cur_TieredPricing_PCT_REC.TIER_ID, 'EUR|JPY|KRW|GBP|TWD|SGD|HKD|USD|AUD|MYR') INTO V_ID_CNT FROM DUAL; 

     DBMS_OUTPUT.put_line('V_ID_CNT is ' || V_ID_CNT); 

     SELECT Cur_TieredPricing_PCT_REC.CALCULATION__TYPE INTO V_CAL_TYPE FROM DUAL; 

     DBMS_OUTPUT.put_line('CALCULATION__TYPE ' || V_CAL_TYPE); 

     IF (UPPER(V_CAL_TYPE) = 'MAXIMUM') THEN 
      DBMS_OUTPUT.put_line('V_CAL_TYPE is maximum'); 

      FOR i IN 1 .. V_ID_CNT LOOP 
       DBMS_OUTPUT.put_line('inside for loop'); 
       insertstatement_1  := 'INSERT INTO ROC_PCT_IPSERVICE_THRSHLD_TST(THRESHOLDUSAGE,RATEAMOUNT,INOUTCD,ISPID) values (Cur_TieredPricing_PCT_REC.THRESHOLD_USAGE_' 
              || i 
              || ',Cur_TieredPricing_PCT_REC.RATE_AMOUNT_' 
              || i 
              || ',' 
              || 'V_IN' 
              || ',' 
              || 'Isp_TR_var' 
              || ');'; 

       DBMS_OUTPUT.put_line('insert statement_1 ' || insertstatement_1); 

       EXECUTE IMMEDIATE insertstatement_1; 

       insertstatement_2  := 'INSERT INTO ROC_PCT_IPSERVICE_THRSHLD_TST(THRESHOLDUSAGE,RATEAMOUNT,INOUTCD,ISPID) values (Cur_TieredPricing_PCT_REC.THRESHOLD_USAGE_' 
              || i 
              || ',Cur_TieredPricing_PCT_REC.RATE_AMOUNT_' 
              || i 
              || ',' 
              || 'V_OUT' 
              || ',' 
              || 'Isp_TR_var' 
              || ');'; 

       DBMS_OUTPUT.put_line('insert statement_2 ' || insertstatement_2); 

       EXECUTE IMMEDIATE insertstatement_2; 

       COMMIT; 
      END LOOP; 
     ELSE 
      DBMS_OUTPUT.put_line('V_CAL_TYPE is not maximum'); 

      FOR i IN 1 .. V_ID_CNT LOOP 
       DBMS_OUTPUT.put_line('inside for loop'); 

       insertstatement  := 'INSERT INTO ROC_PCT_IPSERVICE_THRSHLD_TST(THRESHOLDUSAGE,RATEAMOUNT,INOUTCD,ISPID) values (Cur_TieredPricing_PCT_REC.THRESHOLD_USAGE_' 
             || i 
             || ',Cur_TieredPricing_PCT_REC.RATE_AMOUNT_' 
             || i 
             || ',Cur_TieredPricing_PCT_REC.INOUTCD, Isp_TR_var);'; 

       DBMS_OUTPUT.put_line('insert statement ' || insertstatement); 

       EXECUTE IMMEDIATE insertstatement; 

       COMMIT; 
      END LOOP; 
     END IF; 
    END LOOP; 
END TEST_FINAL; 

答えて

0

REGEXP_COUNTへのコールで左括弧がありません。ほかに、あなたが変数V_CAL_TYPEへの割り当てのためのクエリを必要としない:

CREATE OR REPLACE PROCEDURE TEST_FINAL AS 
    CURSOR Cur_TieredPricing_PCT IS 
      SELECT * 
      FROM IPSERVICE_46PRCT_NO4CASES_TST 
     ORDER BY BILLPROFILEID, TELSTRA_SERVICE_ID; 

    V_ODD_EVN   NUMBER; 
    V_ID_CNT    NUMBER; 
    V_IN     VARCHAR(4) := 'In'; 
    V_OUT    VARCHAR(4) := 'Out'; 
    insertstatement  VARCHAR2(5000); 
    insertstatement_1 VARCHAR2(5000); 
    insertstatement_2 VARCHAR2(5000); 

    Isp_TR_var   VARCHAR2(100) := 'PACNET_U_IPT_ISP_32483'; 

    V_CAL_TYPE   IPSERVICE_46PRCT_NO4CASES.CALCULATION__TYPE%TYPE; 
BEGIN 
    FOR Cur_TieredPricing_PCT_REC IN Cur_TieredPricing_PCT LOOP 
     --- select count from tier_id field 
     SELECT DISTINCT REGEXP_COUNT (Cur_TieredPricing_PCT_REC.TIER_ID, 'EUR|JPY|KRW|GBP|TWD|SGD|HKD|USD|AUD|MYR') INTO V_ID_CNT FROM DUAL; 

     DBMS_OUTPUT.put_line('V_ID_CNT is ' || V_ID_CNT); 

     /* no need for a query 
     SELECT Cur_TieredPricing_PCT_REC.CALCULATION__TYPE INTO V_CAL_TYPE FROM DUAL; 
     */ 
     V_CAL_TYPE := Cur_TieredPricing_PCT_REC.CALCULATION__TYPE; 

     DBMS_OUTPUT.put_line('CALCULATION__TYPE ' || V_CAL_TYPE); 

     IF (UPPER(V_CAL_TYPE) = 'MAXIMUM') THEN 
      DBMS_OUTPUT.put_line('V_CAL_TYPE is maximum'); 

      FOR i IN 1 .. V_ID_CNT LOOP 
       DBMS_OUTPUT.put_line('inside for loop'); 
       insertstatement_1  := 'INSERT INTO ROC_PCT_IPSERVICE_THRSHLD_TST(THRESHOLDUSAGE,RATEAMOUNT,INOUTCD,ISPID) values (Cur_TieredPricing_PCT_REC.THRESHOLD_USAGE_' 
              || i 
              || ',Cur_TieredPricing_PCT_REC.RATE_AMOUNT_' 
              || i 
              || ',' 
              || 'V_IN' 
              || ',' 
              || 'Isp_TR_var' 
              || ');'; 

       DBMS_OUTPUT.put_line('insert statement_1 ' || insertstatement_1); 

       EXECUTE IMMEDIATE insertstatement_1; 

       insertstatement_2  := 'INSERT INTO ROC_PCT_IPSERVICE_THRSHLD_TST(THRESHOLDUSAGE,RATEAMOUNT,INOUTCD,ISPID) values (Cur_TieredPricing_PCT_REC.THRESHOLD_USAGE_' 
              || i 
              || ',Cur_TieredPricing_PCT_REC.RATE_AMOUNT_' 
              || i 
              || ',' 
              || 'V_OUT' 
              || ',' 
              || 'Isp_TR_var' 
              || ');'; 

       DBMS_OUTPUT.put_line('insert statement_2 ' || insertstatement_2); 

       EXECUTE IMMEDIATE insertstatement_2; 

       COMMIT; 
      END LOOP; 
     ELSE 
      DBMS_OUTPUT.put_line('V_CAL_TYPE is not maximum'); 

      FOR i IN 1 .. V_ID_CNT LOOP 
       DBMS_OUTPUT.put_line('inside for loop'); 

       insertstatement  := 'INSERT INTO ROC_PCT_IPSERVICE_THRSHLD_TST(THRESHOLDUSAGE,RATEAMOUNT,INOUTCD,ISPID) values (Cur_TieredPricing_PCT_REC.THRESHOLD_USAGE_' 
             || i 
             || ',Cur_TieredPricing_PCT_REC.RATE_AMOUNT_' 
             || i 
             || ',Cur_TieredPricing_PCT_REC.INOUTCD, Isp_TR_var);'; 

       DBMS_OUTPUT.put_line('insert statement ' || insertstatement); 

       EXECUTE IMMEDIATE insertstatement; 

       COMMIT; 
      END LOOP; 
     END IF; 
    END LOOP; 
END TEST_FINAL; 
+0

REGEXP_COUNTへの呼び出し中に左括弧は私のprocの中に存在していました。私は質問に間違って削除されました。 – Jig232

関連する問題