I try to call to a stored function in a package that returns a number:
function LOGIN(USERNAME in varchar2 default null
, PASSWORD in varchar2 default null)
return number;
It returns 0 or negative integer for failure and a positive integer for success. Here is my PHP code calling the function:
$sql = ":v_res := PACK.LOGIN(:p_user, :p_pass)";
$bindings = [ ':p_user' => 'test', ':p_pass' => '1234', ':v_res' => & $result];
$statement oci_parse($connection, $sql);
foreach ($bindings as $k => & $v) {
oci_bind_by_name($statement, $k, $v, customSizeOf($v), determineSqlType($v));
}
oci_execute($statement);
When I use result as shown (not defined before using in binding) it returns "Undefined variable" warning. If I suppress the warning and move on, it is bound with null, size of -1 and type 1 (SQLT_CHR); If I define result like $result = -1;
, it is bound with -1, size of PHP_INT_SIZE and type 3 (SQLT_INT).
Either way, on execute, this error is produced
ORA-01036: illegal variable name/number