Q:

PHP OCI8 bind by name in function with date datatype

I have to call a procedure in an Oracle DB.
the procedure is like:
procedure test
  (a IN VARCHAR2
  ,b IN INTEGER
  ,c OUT DATE)

I'm calling the procedure as
$sql="BEGIN test(:a, :b, :c); END;";

$smt = oci_parse($db, $sql);
oci_bind_by_name($smt, ':a', $a);
oci_bind_by_name($smt, ':b', $b);
oci_bind_by_name($smt, ':c', $c);
$results = oci_execute($smt);

When c is empty, everything works fine.
But when it has a value, I get this error
oci_execute(): ORA-06502: PL
/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 1&#039;

How can I set the data type as date on calling a producere on a out variable ?

A:

As documented on the oci_bind_by_name manual page:

You must specify maxlength when using an OUT bind so that PHP allocates enough memory to hold the returned value. 

So simply changing:
oci_bind_by_name($smt, ':c', $c);

to:
oci_bind_by_name($smt, ':c', $c, 100); // NOTE: 100 is arbitrary.

should solve the problem.

