You must use an alias to access Object fields in Oracle. (11g)
Examples:
Wrong
SELECT Order.quantity FROM Customers
Wrong
SELECT Customers.Order.quantity FROM Customers
Right
SELECT cc.Order.quantity FROM Customers cc
I assumed that the second option in the list would work, but it doesnt. You have to use an alias.
Working example as per request:
DROP Table tblCustomer;
DROP Table tblOrders;
CREATE OR REPLACE TYPE t_Customer as OBJECT
(custID varchar2(20)
,lastname varchar2(50)
,firstname varchar2(50)
,member function getHighest RETURN NUMBER
);
/
CREATE OR REPLACE TYPE t_Orders AS OBJECT
(OrderID Number
,Customer REF t_Customer
,quantity NUMBER
);
/
CREATE TABLE tblOrders of t_orders;
CREATE TABLE tblCustomer of t_Customer;
CREATE OR REPLACE VIEW OrderOV(ord) AS
SELECT t_orders(OrderID, Customer, quantity) FROM tblOrders;
/
CREATE OR REPLACE VIEW CustomerOV(cust) AS
SELECT t_customer(custID, lastname, firstname) FROM tblCustomer;
/
CREATE OR REPLACE TYPE BODY t_Customer AS
MEMBER Function getHighest RETURN NUMBER IS
v_maxval NUMBER;
BEGIN
SELECT max(orderOV.ord.quantity) INTO v_maxval FROM OrderOV WHERE OrderOV.ord.custID = self.CustID;
END;
end;
/
The line inside the function body can be switched out for the correct aliased version.
SELECT Max(e.ord.quantity) INTO v_maxval FROM OrderOV e WHERE e.ord.customer.custID = self.custID;
You can paste this whole script to test, it compiles when you switch the line in question with the correct line I listed.