Selecting Columns with User Defined Types... in PHP
627716Mar 10 2008 — edited Apr 1 2008I've looked all over google and this forum and can't find anything about this... here's what I've got:
a User Defined Type:
CREATE TYPE "ADDRESS" AS OBJECT (
ADDRESS VARCHAR2(256),
COUNTRY VARCHAR2(256),
STATE VARCHAR2(256),
SUBURB VARCHAR2(256),
TOWNCITY VARCHAR2(256)
)
and it is used in a column in one of my tables:
CREATE TABLE "SUPPLIERS" (
"ID" NUMBER,
"USER_ID" NUMBER,
"NAME" VARCHAR2(50),
"ADDRESS" "ADDRESS"
)
so that column "address" is of type "address". I am then able to insert a row using:
INSERT INTO "SUPPLIERS" VALUES(1,1,'name',ADDRESS('address','country','state','suburb','town city'));
and that all works as expected. I can select the data using iSqlPlus and get the result I expect;
ADDRESS('address', 'country', 'state', 'suburb', 'town city')
So here's the problem. I cannot reterieve the data as expected, using PHP. If I make a select statement on the table that excludes the ADDRESS column I get the results as expected. If the ADDRESS column is included I get an error when fetching the row:
ORA-00932: inconsistent datatypes: expected CHAR got ADT
I'm assuming this is because the the cell cannot be cast to a string. How can I select the row so that the ADDRESS column is returned as an object? Can I even? If I can't, I don't see the use of Object Data Types... :(
I have found that I can select a field of the type using:
SELECT t.ADDRESS.TOWNCITY FROM SUPPLIERS t;
But this is not ideal, because the whole idea was that I could (potentially) change the format for, in my example, an address, and not need to alter my SQL statements.
Any ideas??