Torben G
Torben G

Reputation: 800

OR Database/Type in Oracle Express/SQL Developer

I try to do some stuff wie object relational Databases. I have Oracle Express and the SQL Developer. Everything works fine.

I can create my own, custom types and insert some rows. The problem is that it would not be display right. I think it is normally because they should be display object/types in a column...

Is there a solution to display the objects in the columns?

This is my code. p.s. i am from germany. ANSCHRIFT_T is a type for an address with name of the tress (Strasse) and house number (Hausnr).

CREATE OR REPLACE TYPE ANSCHRIFT_T AS OBJECT (STRASSE CHAR(12), HAUSNR CHAR(3));

CREATE TABLE VERTRETER(V_NR NUMBER(4) PRIMARY KEY, ANSCHRIFT ANSCHRIFT_T);

INSERT INTO VERTRETER VALUES (1, ANSCHRIFT_T('TESTWEG','14'));
INSERT INTO VERTRETER VALUES (2, ANSCHRIFT_T('BLA BLA WEG', '25'));

SELECT V_NR, ANSCHRIFT FROM VERTRETER;

But the output its just this:

enter image description here

Upvotes: 1

Views: 95

Answers (2)

MT0
MT0

Reputation: 168681

You need to add an alias for the table name and then you can select the values from the object column using table_alias.object_column.object_attribute. Like this:

Query:

SELECT V_NR,
       v.ANSCHRIFT.STRASSE,
       v.ANSCHRIFT.HAUSNR
FROM   VERTRETER v;

Output:

      V_NR ANSCHRIFT.STRASSE ANSCHRIFT.HAUSNR
---------- ----------------- ----------------
         1 TESTWEG           14               
         2 BLA BLA WEG       25               

Upvotes: 0

thatjeffsmith
thatjeffsmith

Reputation: 22467

Double click on the value. You'll see your data.

double click in the bracketed text

Or, you can tell SQL Developer to show those values by default.

Preferences > Advanced, display structures

Turn this on

And then run your query again.

[Voila[3]

Upvotes: 1

Related Questions