I create an object type and a table with a column of that type:
CREATE TYPE food_t AS OBJECT (
NAME VARCHAR2 (100)
, food_group VARCHAR2 (100)
, grown_in VARCHAR2 (100)
)
/
CREATE TABLE food_table (id number primary key, my_food food_t)
/
BEGIN
INSERT INTO food_table
VALUES (1, NEW food_t ('Mutter Paneer', 'Curry', 'India'));
INSERT INTO food_table
VALUES (2, NEW food_t ('Cantaloupe', 'Fruit', 'Backyard'));
COMMIT;
END;
/
But when I try to get the names of my good, I get the ORA-904 error:
SELECT name FROM food_table;
ORA-00904: "NAME": invalid identifier
Same if I use the name of the object type column:
SELECT my_food.name FROM food_table;
ORA-00904: "NAME": invalid identifier
What am I doing wrong?