Binding PHP Arrays to Oracle Arrays in OCI library - can you do it?
| From: | Neil Kimber | Date: | Fri, 06 Jul 2001 10:38:48 +0000 |
| Subject: | Binding PHP Arrays to Oracle Arrays in OCI library - can you do it? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-56476@lists.php.net to get a copy of this message | ||
We have a nice PHP framework that handles all of of our interactions with
Oracle via OCI calls. It works beautifully and gives us no problems.
However, the one thing that we cannot get working is the calling of an
Oracle stored procedure that takes an array of numbers as an argument. The
problem seems to be the binding in PHP.
Let me give an example.
The stored procedure looks like:
FUNCTION MY_TEST(TRANSPORT_ROUTES_IN NUMBER_ARRAY) RETURN PLS_INTEGER IS
BEGIN
RETURN TRANSPORT_ROUTES_IN.COUNT;
END SUMESH_TEST;
We try and access the stored procedure in PHP by:
$prpTransRoute_Id = array(1,2,3);
$stmt = OCIParse($conn, "declare rtrn integer; begin :rtrn := MY_TEST
(TRANSPORT_ROUTES_IN =>:TRouteID); end; ");
OCIBindByName($stmt, "rtrn", &$rtrn, 32);
OCIBindByName($stmt,":TRouteID",&$prpTransRoute_Id,-1);
OCIExecute($stmt);
We get an error stating:
Array to string conversion
OCIStmtExecute: ORA-06550: line 1, column 18:
PLS-00306: wrong number or types of arguments in call to 'MY_TEST'
ORA-06550: line 1, column 29:
PL/SQL: Statement ignored
Returning DB Error: Execute didn't work : declare rtrn integer; begin :rtrn
:= MY_TEST (TRANSPORT_ROUTES_IN =>:TRouteID); end;
Oracle specific error code => 6550 message => ORA-06550: line 1, column 18:
PLS-00306: wrong number or types of arguments in call to 'MY_TEST'
PL/SQL: Statement ignored
I believe that the problem is that I'm not binding the array correctly. I'm
not even sure if it is possible to bind arrays in PHP to numeric arrays in
Oracle. Has anyone ever managed to do this. If so, what are the rules for
binding?
Thanks in advance,
Neil Kimber
Front End Team Leader - flytxt
5-15 Cromer Street,
London, WC1H 8LS
Mob: +44-793-049-0666
Fax: +44-207-841-6444
Mail: neil.kimber@flytxt.com
Website: http://www.flytxt.com/