Home » SQL & PL/SQL » SQL & PL/SQL » object type (sql command line)
object type [message #602947] Tue, 10 December 2013 08:58 Go to next message
aravindreddy.akiti
Messages: 14
Registered: October 2013
Location: hyderabad
Junior Member
i created objects like below
1.create or replace type name_type as object
(first_name varchar2(10),
last_name varchar2(10)
);/
2.create or replace type address_type as object
(h_no varchar2(10),
building varchar2(10),
street varchar2(10)
);/
And here i created a table like below
create table details
(name name_type,
address address_type);
now i want to insert the data how do i insert the into the table
pls answer me
Re: object type [message #602949 is a reply to message #602947] Tue, 10 December 2013 09:05 Go to previous messageGo to next message
ThomasG
Messages: 3211
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Are you really sure you want to do that?

You can of course create and insert those types.

INSERT INTO details VALUES (
  name_type('First','Last'), 
  address_type('fo','build','str')
);


But now how do you select it again? A lot of tools/drivers won't be able to. You can't really use the table over db links easily. In general it is a bad idea to store custom objects in tables, stick to standard types for storage or you will find yourself in a deep hole one day and no way to get out again.
Re: object type [message #602952 is a reply to message #602949] Tue, 10 December 2013 09:16 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>In general it is a bad idea to store custom objects in tables, stick to standard types for storage or you will find yourself in a deep hole one day and no way to get out again.

I TOTALLY agree with this advice!
Re: object type [message #602954 is a reply to message #602952] Tue, 10 December 2013 09:50 Go to previous messageGo to next message
aravindreddy.akiti
Messages: 14
Registered: October 2013
Location: hyderabad
Junior Member
then what is the best way to store data
Re: object type [message #602955 is a reply to message #602954] Tue, 10 December 2013 09:55 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>then what is the best way to store data

do not use TYPE datatype
Re: object type [message #602957 is a reply to message #602954] Tue, 10 December 2013 09:56 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
aravindreddy.akiti wrote on Tue, 10 December 2013 15:50
then what is the best way to store data


ThomasG wrote on Tue, 10 December 2013 15:05
stick to standard types for storage
Re: object type [message #602960 is a reply to message #602957] Tue, 10 December 2013 10:10 Go to previous messageGo to next message
aravindreddy.akiti
Messages: 14
Registered: October 2013
Location: hyderabad
Junior Member
what i use here instead of TYPE datatype
Re: object type [message #602961 is a reply to message #602960] Tue, 10 December 2013 10:12 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
5 columns all of standard types.
Re: object type [message #602962 is a reply to message #602960] Tue, 10 December 2013 10:14 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
We're not suggesting there's some other objecty way of storing the data.
We're suggesting you should store the data in normal columns in a normal table.
 create table details
 (first_name varchar2(10),
 last_name varchar2(10),
 h_no varchar2(10),
 building varchar2(10),
 street varchar2(10));
Previous Topic: need Regular expression query
Next Topic: dbms_output.put_line
Goto Forum:
  


Current Time: Tue Apr 23 10:46:23 CDT 2024