I have two entities, Customer and Order, both of which I have created types for. The SQL type declarations are:
CREATE OR REPLACE TYPE "CUSTOMERTYPE" AS OBJECT (
customerId CHAR(6),
name VARCHAR2(50),
address VARCHAR2(255),
telephone CHAR(11)
);
CREATE OR REPLACE TYPE "ORDERTYPE" AS OBJECT (
customer REF CustomerType,
orderId CHAR(10),
orderDate DATE,
totalCost FLOAT
);
The idea being that a customer can place 1..* orders. An order is placed by 1..1 customer.
I've also created CustomerTable and OrderTable tables like so:
CREATE TABLE "CUSTOMERTABLE" OF "CUSTOMERTYPE";
CREATE TABLE "ORDERTABLE" OF "ORDERTYPE";
There is an entry in CustomerTable with customerId = '123456'. When I execute the following:
INSERT INTO OrderTable
SELECT OrderType (REF(c), '1234567890', '02-Nov-2009', 99)
FROM CustomerTable c
WHERE c.customerId = '123456';
Oracle reports that the row has been inserted. However, when I check the data I get error:
ORA-00932: inconsistent datatypes: expected NUMBER got REF MILKPLUSVELLOCET.CUSTOMERTYPE
Any help would be greatly appreciated.