ID: 40186
Updated by: [EMAIL PROTECTED]
Reported By: tony at marston-home dot demon dot co dot uk
-Status: Open
+Status: Assigned
Bug Type: OCI8 related
Operating System: Windows XP
PHP Version: 5.2.0
-Assigned To:
+Assigned To: tony2001
Previous Comments:
------------------------------------------------------------------------
[2007-01-21 13:51:22] tony at marston-home dot demon dot co dot uk
Description:
------------
I am using the latest OCI8 extension from PECL.
I have created a database table which contains a VARRAY user-defined
type as follows:
CREATE OR REPLACE TYPE t_fav_food IS VARRAY(10) OF NUMBER(2);
CREATE TABLE x_person (
person_id varchar2(8) NOT NULL,
first_name varchar2(20) NOT NULL,
last_name varchar2(30) NOT NULL,
favourite_food t_fav_food,
PRIMARY KEY (person_id)
);
I can write a record containing a VARRAY type, but I am unable to read
it as oci_fetch_array() fails with error ORA-00932.
Reproduce code:
---------------
<?php
$dbconn = ociLogon('tony', 'tony', '//localhost/xe') or die('unable to
connect to database');
$query = "TRUNCATE TABLE x_person";
$stmt = oci_parse($dbconn, $query);
$result = oci_execute($stmt, OCI_COMMIT_ON_SUCCESS) or die('truncate
failed');
$query = "INSERT INTO x_person (person_id, first_name, last_name,
favourite_food) VALUES ('AJM','Tony','Marston', t_fav_food(1,3,5))";
$stmt = oci_parse($dbconn, $query);
$result = oci_execute($stmt, OCI_COMMIT_ON_SUCCESS) or die('insert #1
failed');
$query = "INSERT INTO x_person (person_id, first_name, last_name,
favourite_food) VALUES ('FB','Fred','Bloggs', t_fav_food(2,4,6))";
$stmt = oci_parse($dbconn, $query);
$result = oci_execute($stmt, OCI_COMMIT_ON_SUCCESS) or die('insert #2
failed');
$query = "SELECT * FROM x_person";
$stmt = oci_parse($dbconn, $query);
$result = oci_execute($stmt) or die('select failed');
while ($row = @oci_fetch_array ($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
$array[] = array_change_key_case($row, CASE_LOWER);
} // while
if ($error_array = oci_error($stmt)) {
echo 'Error code: ' .$error_array['code'] ."\r\n";
echo 'Error msg : ' .$error_array['message'] ."\r\n";
exit();
} // if
echo 'Done';
?>
Expected result:
----------------
I expect the VARRAY column to be made available in my program so that
it can be processed using the oci-collection methods, similar to the
way CLOBs and BLOBs are handled.
This is what I can already do with the SET type in MySQL, and the ARRAY
type in PostgreSQL.
Actual result:
--------------
The call to oci_fetch_array() fails with ORA-00932: inconsistent
datatypes: expected CHAR got ARRAY. This means that I am unable to read
table that contains a VARRAY column.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40186&edit=1