Reputation: 47
I have a collection types in oracle defined like that :
CREATE OR REPLACE TYPE "NUM_ARRAY" AS TABLE OF NUMBER(8,0)
and stored procedure :
PROCEDURE choice ( name IN VARCHAR2, order IN NUM_ARRAY )
How to do bind param with pdo and php like that ? : $stmt->bindParam(':order ',...);
Thx
Upvotes: 2
Views: 932
Reputation: 26
I don't know if you are still looking for an answer to this question, but I will give you my answer in case others are having the same problem. I found my answer at the following link.
http://www.oracle.com/technetwork/articles/fuecks-sps-095636.html
Here is a function that I created to pass parameters to an Oracle procedure. The procedure that I am using is not returning any results so therefore this function does not catch anything.
public function bindVariablesToProcedure($var1, $var2, $var3)
{
$rtn = []; // initalize array
if($this->dbconnect)
{
/* schema is your database schema
BindVariable is your stored procedure */
$bindSql = 'BEGIN schema.BindVariable(:var1, :var2, :var3); END;';
/* The numbers for the fourth parameter are the character lengths
that are in my database. I found that without these numbers
the "oci_bind_by_name" function would error out. */
$bindRes = oci_parse($this->dbconnect, $bindSql);
oci_bind_by_name($bindRes, ':var1', $var1, 100);
oci_bind_by_name($bindRes, ':var2', $var2, 5);
oci_bind_by_name($bindRes, ':var3', $var3, 100);
if(oci_execute($bindRes))
{
$rtn['status'] = "success";
}
else
{
$e = oci_error($bindRes); // For oci_execute errors pass the statement handle
$rtn['bindErrorSql'] = $e['sqltext'];
$rtn['bindErrorCode'] = $e['code'];
$rtn['bindErrorMsg'] = $e['message'];
$rtn['status'] = "failed";
}
}
return $rtn;
}
Upvotes: 1