I have the following types and tables:
CREATE TYPE person AS OBJECT (
dni VARCHAR2(10),
name VARCHAR2(30),
surname VARCHAR2(100)
)NOT FINAL;
CREATE TYPE runner UNDER person (
runningClub VARCHAR2(100)
);
CREATE TYPE race AS OBJECT (
name VARCHAR2(50),
city VARCHAR2(50),
distance INTEGER
)NOT FINAL;
CREATE TYPE participation UNDER race(
runner_id runner,
year VARCHAR(4),
time INTEGER
);
CREATE TABLE participations OF participation;
And now I need to create a VIEW and I tried this:
CREATE VIEW AvgTime10k OF PARTICIPATION WITH OBJECT IDENTIFIER (runner_id, year, time) AS
SELECT runner_id, time FROM PARTICIPATIONS WHERE DISTANCE = '10';
But the error I get is: Error SQL: ORA-01730: invalid number of column names specified
Anybody knows why? It's my first time with object-relational SQL and this is struggling me a lot. Thanks!
participationobject repeats all the common fields from the race. Shouldn'tparticipationhaveraceandrunnerattributes - possibly as refs to tables of those; and shouldn'tyear(or the full race date) be part of the race definition?