0

Part of my homework. I know this is quite basic, but it is not so intuitive for me. I create this:

    CREATE TYPE Address_typ AS OBJECT (
      AddressNo  NUMBER,
      Street    VARCHAR2(64),
      PostCode  VARCHAR2(9),
      Town      VARCHAR2(64)
      );
    /

    CREATE TYPE Customer_typ AS OBJECT (
      CustNo         NUMBER,
      customer_name  VARCHAR2(64),
      VAT_NO         VARCHAR2(18),
      Address_ref    REF Address_typ
      );
    /

CREATE TABLE Address_table OF Address_typ;

CREATE TABLE Customer_table OF Customer_typ
(Address_ref SCOPE IS Address_table);

this insert works:

INSERT INTO Address_table VALUES(Address_typ(1,'Strumykowa 5','65-001', 'Zielona Góra'));

and one below is not (with empty Address_table):

INSERT INTO Customer_table VALUES(Customer_Typ(1,'PPUH ZZPD', '12345678901', Address_typ(1,'Strumykowa 5','65-001', 'Zielona Góra')));

How should I insert correctly into Customer_table

1
  • should the Customer_typ be relative?... I guess not necessary. Commented Jan 27, 2016 at 21:14

1 Answer 1

2

This way will work:

INSERT INTO Customer_table
VALUES(Customer_Typ(1,'PPUH ZZPD', '12345678901', (select ref(a) from address_table a where a.AddressNo = 1)));
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, strange that I didn't figure it out myself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.