Home » SQL & PL/SQL » SQL & PL/SQL » object type (sql developer)
object type [message #601633] Sat, 23 November 2013 09:12 Go to next message
aravindreddy.akiti
Messages: 14
Registered: October 2013
Location: hyderabad
Junior Member
i done here,
create or replace type person_name_type as object
( first_name varchar2(10),
middle_name varchar2(10),
last_name varchar2(10) );
and
create table name
( name person_name_type not null
);
here i want to insert first_name,middle_name,last_name how can i insert.
please give me reply
Re: object type [message #601634 is a reply to message #601633] Sat, 23 November 2013 09:25 Go to previous messageGo to next message
BlackSwan
Messages: 22506
Registered: January 2009
Senior Member
when all else fails Read The Fine Manual

http://docs.oracle.com/cd/B28359_01/appdev.111/b28371/adobjplsql.htm#CIHDFEDI

Realize that CREATE TYPE is a PL/SQL object; not a SQL object
PL/SQL & SQL are entirely separate & distinct different languages!
Re: object type [message #601647 is a reply to message #601633] Sat, 23 November 2013 12:29 Go to previous messageGo to next message
Solomon Yakobson
Messages: 1956
Registered: January 2010
Senior Member
Just insert:

SQL> create or replace type person_name_type as obje
  2  ( first_name varchar2(10),
  3  middle_name varchar2(10),
  4  last_name varchar2(10) );
  5  /

Type created.

SQL> create table name
  2  ( name person_name_type not null
  3  );

Table created.

SQL> select  *
  2    from  name
  3  /

NAME(FIRST_NAME, MIDDLE_NAME, LAST_NAME)
----------------------------------------------------
PERSON_NAME_TYPE('Joe', 'M', 'Schmoe')

SQL>


SY.
Re: object type [message #601669 is a reply to message #601647] Sun, 24 November 2013 01:59 Go to previous messageGo to next message
Lalit Kumar B
Messages: 1826
Registered: May 2013
Location: World Wide on the Web
Senior Member
SY missed to post the insert statement :

SQL> INSERT INTO name VALUES
  2      (PERSON_NAME_TYPE('Joe', 'M', 'Schmoe')
  3      );

1 row created.


Re: object type [message #601678 is a reply to message #601669] Sun, 24 November 2013 06:00 Go to previous message
Solomon Yakobson
Messages: 1956
Registered: January 2010
Senior Member
Thanks Lalit. Cur & paste error.

SY.
Previous Topic: multiple select from one table
Next Topic: how to make a column primary key which contains duplicate data
Goto Forum:
  


Current Time: Sat Jul 26 03:05:47 CDT 2014

Total time taken to generate the page: 0.08517 seconds