Search code examples
sqloracle-databasesqlplusobject-relational-model

Oracle sqlplus - defining typed table with no attributes but nested tables


I have an problem with my homework. I have the following type definitions:

-- Type definitions
CREATE OR REPLACE TYPE languages_table_t AS TABLE of VARCHAR2(20);
/

CREATE OR REPLACE TYPE phones_table_t AS TABLE of NUMBER;
/

CREATE OR REPLACE TYPE tourist_t AS OBJECT (
  -- ...
  -- some simple attrubutes
  -- one attribute of user defined type
  -- more simple attrubutes
  -- ...
) NOT FINAL;
/

CREATE OR REPLACE TYPE guide_t UNDER tourist_t (
  languages   languages_table_t,
  phones      phones_table_t
);
/
-- All types are created successfully


-- table definitions:

CREATE TABLE Tourist OF tourist_t (
  -- all simple attributes with nullity constraints
  CONSTRAINT PK_TOURIST PRIMARY KEY (username),
) NESTED TABLE the_UDT_attr STORE AS the_user_defined_type;
-- Created successfully

CREATE TABLE Guide OF guide_t (
  CONSTRAINT PK_GUIDE PRIMARY KEY (username)
) NESTED TABLE languages STORE AS guide_languages
  NESTED TABLE phones STORE AS guide_phones;
-- returns mystic error

when running the last create instruction, I get the following error:

CREATE TABLE Guide OF guide_t (
*
ERROR at line 1:
ORA-22913: must specify table name for nested table column or attribute

I've searched for this error, but it seems too specific to my definitions, and I couldn't find how to solve it. Please, any help will be appreciated. I need an idea about how to attack these kind of errors, how to solve them or where to read about it.

The version of sqlplus is:

SQL> SELECT * FROM V$VERSION;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0  Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

If you need any other info to help me, please ask, and I'll update the question.

Thanks!


Solution

  • Nested table storage also needs to be defined for the attributes of the supertype. The udt_tables.sql script works when I add this to line 155:

    CREATE TABLE Guia OF guia_t (
      CONSTRAINT PK_GUIA PRIMARY KEY (username)
    ) NESTED TABLE idiomas STORE AS guia_idiomas
      NESTED TABLE telefonos STORE AS guia_telefonos
      NESTED TABLE tipoHitosPreferidos STORE as something;