2

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

1 Answer 1

1

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;
}    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.