QUESTION POSED ON: 21 April 2006
I am working in JDEVELOPER using JDBC. This program is working with objects. I am getting this error on a SQL statement: "java.sql.SQLException: ORA-00904: "R": invalid identifier." The select statement is:
SELECT VALUE(r)
FROM Rectangles r
I do not understand why I am getting an error on the select. How do I fix this? It seems like object r is not connected to anything somehow. Thanks for your help.
I have provided the supporting documentation below. The create of the objects and tables are as follows:
CREATE TYPE point_type AS OBJECT (
x NUMBER,
y NUMBER);
/
CREATE TABLE circles (
radius NUMBER,
center point_type);
/
CREATE TABLE bloom_data OF point_type;
/
INSERT INTO bloom_data values(2,3);
INSERT INTO bloom_data values(3,15);
INSERT INTO circles values
(3,point_type(5,5));
/
CREATE TYPE rectangle_type AS OBJECT (
top_left point_type,
width NUMBER,
height NUMBER,
MAP MEMBER FUNCTION getarea RETURN NUMBER, MEMBER FUNCTION CONTAINS(pt IN point_type) RETURN NUMBER); /
CREATE OR REPLACE TYPE BODY rectangle_type AS
MAP MEMBER FUNCTION getarea RETURN NUMBER AS
BEGIN
RETURN width * height;
END;
MEMBER FUNCTION CONTAINS
(pt IN point_type) RETURN NUMBER AS
is_inside NUMBER := 0;
BEGIN
IF (pt.x > top_left.x
AND pt.x < top_left.x + width
AND pt.y > top_left.y
AND pt.y < top_left.y + height)
THEN
is_inside := 1;
END IF;
RETURN is_inside;
END;
END;
/
CREATE TABLE rectangles (
label VARCHAR2(25),
rectangle rectangle_type);
/
INSERT INTO rectangles VALUES ('ONE',
rectangle_type(point_type(10,50),40,20));
/
INSERT INTO rectangles VALUES ('TWO',
rectangle_type(point_type(0,0),10,10));
/
|