Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8946865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:36:26+00:00 2026-06-15T12:36:26+00:00

Basically, I want to create references to records, one record type is a supertype

  • 0

Basically, I want to create references to records, one record type is a supertype of the other. I am a bit confused over it.

Here are my types:

 CREATE OR REPLACE TYPE  module_t AS OBJECT (
     moduleCode# char(4),
     moduleName char(10)
) NOT FINAL;
/

CREATE OR REPLACE TYPE  specialised_module_t under module_t (
     someSpecialAttribute char(10)
);
/

CREATE OR REPLACE TYPE  course_t AS OBJECT (
     courseCode# char(4),
     module1 REF module_t,
     module2 REF specialised_module_t
);
/

Here are my tables:

CREATE TABLE module_tab OF module_t(
    moduleCode# PRIMARY KEY NOT NULL
);

CREATE TABLE course_tab OF course_t(
    courseCode# PRIMARY KEY NOT NULL,
    scope for (module1) is module_tab,
    scope for (module2) is module_tab
);

I insert a record into the module table consisting of a standard module:

insert into module_tab values(
'm001', 'physics'
);

I insert a record into the module table consisting of a specialised module:

insert into module_tab
    values( specialised_module_t(
    'm002',
    'physics',
    'special'
    )
);

Here is the tricky bit:

I want to create a course record in the course table. In this record, the module1 attribute needs to reference module m001 (the first module record) and the module2 attribute needs to reference module m002

I have thought maybe it would look something like this:

INSERT into course_tab VALUES(
       'c001',
        SELECT REF(c) FROM module_tab c WHERE c.moduleCode# = 'm001',
        SELECT REF(c) FROM module_tab c WHERE c.moduleCode# = 'm002'
)

This just doesn’t work 🙁

Here is the error message:

ERROR at line 3:
ORA-00936: missing expression

Obviously my syntax is wrong, but I don’t know how to correct it :/

I have spent ages on this and I can’t figure it out 🙁
Help will be much appreciated 😀
Thanks

UPDATE:

With help from @a_horse_with_no_name my new code is:

INSERT into course_tab VALUES(
       'c001',
        (SELECT REF(c) FROM module_tab c WHERE c.moduleCode# = 'm001'),
        (SELECT treat(REF(c) as ref specialised_module_t) FROM module_tab c WHERE treat(values(c) as moduleCode).person# = 'm002')
);

But now I get the error:

ERROR at line 4:
ORA-00936: missing expression

please help, thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:36:26+00:00Added an answer on June 15, 2026 at 12:36 pm

    If you want to use a SELECT statement to insert a scalar value inside the VALUES clause, you need to put the SELECT statement betweeen parentheses:

    INSERT into course_tab 
       (coursecode#, module1, module2)
    VALUES 
       (
        'c001',
        (SELECT REF(c) FROM module_tab c WHERE c.moduleCode# = 'm001'),
        (SELECT REF(c) FROM module_tab c WHERE c.moduleCode# = 'm002')
       );
    

    Although when I tried it with your example (which, by the way has still lots of other syntax errors) I got the error message:

    ORA-00932: inconsistent datatypes: expected REF SPECIALISED_MODULE_T got REF MODULE_T [SQL State=42000, DB Errorcode=932]

    I don’t really know what to do with that though (as I said I haven’t really worked with Oracle object types, and the table definition for course_tab is completely new to me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I want to create one large object of many object in JavaScript. Something
So basically I want to create a GUI app using PySide and the Qt
I have php generating html and I want to create layers. Basically I want
I want to create own filetype to save objects in my app. Basically, I
I want to create a Google Docs document from within Haskell, so basically I
How to create imaged scrollbars, for example: http://www.openstudio.fr/jquery/index.htm Basically, I want to create my
Ok, so the title is a bit convoluted. This is basically a greatest-n-per-group type
Here's what I'd like to do: I want to create a library project that
I want to create a way to update references to css files in jsf
Basically what I have is an image gallery. Just tried to create one for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.