PHP调用Oracle存储过程时的错误:ORA-06502: PL/SQL: numeric or value error: character string buffer too small

刚刚试着用PHP 的oci8 函数集去调用一个存储过程时总是查询失败且返回以下错误,很是郁闷。。

 

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

 

后来发现是在使用oci_bind_by_name() 函数时没有为绑定的输出变量预先分配好存储的缓冲区大小,例如:

oci_bind_by_name($stmt, ':v_retmsg', $v_retmsg); 

应该写成:

oci_bind_by_name($stmt, ':v_retmsg', $v_retmsg, 100); 

指定的这个长度应该要足够大,如果上例中$v_retmsg 超过了100,同样会执行失败且报错。

你可能感兴趣的:(PHP调用Oracle存储过程时的错误:ORA-06502: PL/SQL: numeric or value error: character string buffer too small)