Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle ORA-06502:PL/SQL:数字或值错误:第一次调用时出现字符到数字转换错误_Oracle_Plsql - Fatal编程技术网

Oracle ORA-06502:PL/SQL:数字或值错误:第一次调用时出现字符到数字转换错误

Oracle ORA-06502:PL/SQL:数字或值错误:第一次调用时出现字符到数字转换错误,oracle,plsql,Oracle,Plsql,我有下面的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 ) 批次id为编号(18,0),p_名称为

我有下面的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
              )
批次id为编号(18,0),p_名称为VARCHAR2(50个字符)

我正在和你联系

insert_p (l_batch_rec, p_batch_id, p_name); 
其中p_batch_id:=NULL,p_name:=NULL

我只有在第一次运行该过程时才出现转换错误。如果我再次运行而不做任何更改,则运行正常。为了重现错误,我断开连接并再次连接


您知道为什么会出现此错误以及如何解决此错误吗?

此错误是否发生在函数使用的包的初始化部分

您应该能够轻松找到错误发生的确切位置。默认情况下,Oracle将显示错误的对象和行号。(虽然,让我非常沮丧的是,我发现人们编写
是很常见的,而其他人则[糟糕的日志记录会抛出行号]

1) 2)
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>