2012-03-23 32 views
0

私が持っている以下のPL/SQLプロシージャORA-06502:PL/SQL:数値または値のエラー:番号変換エラーの文字が最初の呼び出しで表示されます

PROCEDURE insert_p(
       p_batch_rec IN ra_batches%rowtype, 
       p_batch_id OUT NOCOPY ra_batches.batch_id%type, 
       p_name  OUT NOCOPY ra_batches.name%type 
      ) 

batch_idあるNUMBER(18,0)と= NULLとP_NAME::= NULL

P_NAMEはVARCHAR2(50 CHAR)

である私は

insert_p (l_batch_rec, p_batch_id, p_name); 

p_batch_idで手続きを呼んでいます0

変換エラーは、初めてプロシージャを実行したときにのみ得られます。私が変更なしでもう一度走れば、うまくいく。エラーを再現するために、私は切断して再度接続します。

なぜこのエラーが発生し、どのように解決すればよいですか?

+0

1)http://stackoverflow.com/questions/how-to-ask 2)のhttp: //catb.org/~esr/faqs/smart-questions.html#before – zep

答えて

1

機能で使用されているパッケージの初期化部分でエラーが発生しましたか?

エラーが発生した場所を簡単に見つけることができます。デフォルトでは、Oracleはオブジェクトとエラーの行番号を表示します。 (私の大きな不満に、私は人々がwhen others then [poor logging that throws out line number]を書くことのために、それは非常に一般的であることがわかり、けれども。)

SQL> --Create package 
SQL> create or replace package test_package is 
    2  procedure test_procedure; 
    3  conversion_error number; 
    4 end; 
    5/

Package created. 

SQL> --Create package body. Note the initialization part that will fail. 
SQL> create or replace package body test_package is 
    2  procedure test_procedure is 
    3  begin 
    4    null; 
    5  end; 
    6 begin 
    7  conversion_error := 'This is not a number'; 
    8 end; 
    9/

Package body created. 

SQL> --This will fail the first time 
SQL> begin 
    2  test_package.test_procedure; 
    3 end; 
    4/
begin 
* 
ERROR at line 1: 
ORA-06502: PL/SQL: numeric or value error: character to number conversion error 
ORA-06512: at "JHELLER.TEST_PACKAGE", line 7 
ORA-06512: at line 2 


SQL> --But will now work until you reconnect, or run DBMS_SESSION.RESET_PACKAGE. 
SQL> begin 
    2  test_package.test_procedure; 
    3 end; 
    4/

PL/SQL procedure successfully completed. 

SQL> 
関連する問題