Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2013
    Posts
    3

    Question Unanswered: Oracle Crashing every time I run my code.

    Been trying to run this code for ages on oracle it has been crashing each time I've ran it. I've looked at it a few times and I cant see what could be wrong with the code. It crashes after it creates a type.
    CREATE OR REPLACE TYPE address_type AS OBJECT (
    street VARCHAR2(25),
    city VARCHAR2(25),
    country VARCHAR2(20) );
    /

    CREATE TABLE user_address OF address_type;

    CREATE OR REPLACE TYPE contact_type AS OBJECT(
    room_number NUMBER(2),
    capacity NUMBER(2),
    description VARCHAR2(200));
    /

    CREATE TYPE contact_varray_type AS VARRAY(50) OF contact_type;

    CREATE TABLE student (
    student_id NUMBER(6),
    student_title VARCHAR2(5),
    student_fname VARCHAR2(15),
    student_lname VARCHAR2(15),
    address REF address_type SCOPE IS user_address,
    contact contact_varray_type,
    gender CHAR(1));

    CREATE TABLE course(
    course_id NUMBER(3),
    course_name VARCHAR2(20),
    description VARCHAR2(30);


    CREATE TABLE student_enrolment(
    enrolment_id NUMBER(7),
    student_id NUMBER(6),
    module_id NUMBER(4));

    CREATE TABLE course_module(
    course_id NUMBER(3),
    module_id NUMBER(4));

    CREATE TABLE module(
    module_id NUMBER(4),
    module_name VARCHAR2(20),
    description VARCHAR2(30));

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    syntax error above & corrected below

    CREATE TABLE course(
    course_id NUMBER(3),
    course_name VARCHAR2(20),
    description VARCHAR2(30));
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Nov 2013
    Posts
    3
    Quote Originally Posted by anacedent View Post
    syntax error above & corrected below

    CREATE TABLE course(
    course_id NUMBER(3),
    course_name VARCHAR2(20),
    description VARCHAR2(30));
    Tried that and its still not working.
    Attached Thumbnails Attached Thumbnails 9981cc11d339ff1e8a9b3305d566114d.png  

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    works OK for me

    Code:
    SQL> @ds1
    SQL> DROP   TABLE course;
    
    Table dropped.
    
    SQL> DROP   TABLE student_enrolment;
    
    Table dropped.
    
    SQL> DROP   TABLE course_module;
    
    Table dropped.
    
    SQL> DROP   TABLE module;
    
    Table dropped.
    
    SQL> DROP   TABLE student;
    
    Table dropped.
    
    SQL> DROP   TABLE user_address;
    
    Table dropped.
    
    SQL> DROP   TYPE address_type;
    
    Type dropped.
    
    SQL> DROP   TYPE contact_varray_type;
    
    Type dropped.
    
    SQL> DROP   TYPE contact_type;
    
    Type dropped.
    
    SQL> 
    SQL> CREATE TABLE course(
      2  course_id        NUMBER(3),
      3  course_name         VARCHAR2(20),
      4  description         VARCHAR2(30));
    
    Table created.
    
    SQL> 
    SQL> 
    SQL> CREATE TABLE student_enrolment(
      2  enrolment_id       NUMBER(7),
      3  student_id  NUMBER(6),
      4  module_id        NUMBER(4));
    
    Table created.
    
    SQL> 
    SQL> CREATE TABLE course_module(
      2  course_id        NUMBER(3),
      3  module_id        NUMBER(4));
    
    Table created.
    
    SQL> 
    SQL> CREATE TABLE module(
      2  module_id        NUMBER(4),
      3  module_name         VARCHAR2(20),
      4  description         VARCHAR2(30));
    
    Table created.
    
    SQL> 
    SQL> CREATE OR REPLACE TYPE address_type AS OBJECT (
      2  street      VARCHAR2(25),
      3  city        VARCHAR2(25),
      4  country  VARCHAR2(20) );
      5  /
    
    Type created.
    
    SQL> CREATE OR REPLACE TYPE contact_type AS OBJECT(
      2  room_number NUMBER(2),
      3  capacity NUMBER(2),
      4  description VARCHAR2(200));
      5  /
    
    Type created.
    
    SQL> CREATE TYPE contact_varray_type AS VARRAY(50) OF contact_type;
      2  /
    
    Type created.
    
    SQL> CREATE TABLE user_address OF address_type;
    
    Table created.
    
    SQL> 
    SQL> CREATE TABLE student (
      2  student_id NUMBER(6),
      3  student_title VARCHAR2(5),
      4  student_fname VARCHAR2(15),
      5  student_lname VARCHAR2(15),
      6  address REF address_type SCOPE IS user_address,
      7  contact contact_varray_type,
      8  gender CHAR(1));
    
    Table created.
    
    SQL>
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Nov 2013
    Posts
    3
    Strange. I'll have to test it on another system. Thanks for your help.

  6. #6
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Quote Originally Posted by DailySnail View Post
    Strange. I'll have to test it on another system. Thanks for your help.
    Why do you think that changing computer will do the trick?

    If you look closely at anacedent's test, you will notice he added a required back-slash after the CREATE TYPE statement.


    PS: "Oracle Crashing every time I run my code." is somewhat exaggerating the issue.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  7. #7
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    I would suggest you use a daughter table for the address. Using a type definition makes the code overly complicated and non portable.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •