Home » SQL & PL/SQL » SQL & PL/SQL » object type (sql command line)
object type [message #602977] Tue, 10 December 2013 11:27 Go to next message
aravindreddy.akiti
Messages: 14
Registered: October 2013
Location: hyderabad
Junior Member
create or replace type phone_type as object
(phone_number number(10),
phone_type char(1) default 'R' check (phone_type in ('R','O','P'))
;
/
WARNING: type created with compilation error.

how can i solve it, pls answer me
Re: object type [message #602978 is a reply to message #602977] Tue, 10 December 2013 11:31 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

SQL> create or replace type phone_type as object
  2  (phone_number number(10),
  3  phone_type char(1) default 'R' check (phone_type in ('R','O','P'))
  4  ;
  5  /

Warning: Type created with compilation errors.

SQL> sho err
Errors for TYPE PHONE_TYPE:
LINE/COL
-------------------------------------------------------------------------------
ERROR
-------------------------------------------------------------------------------
3/32
PLS-00103: Encountered the symbol "CHECK" when expecting one of the following:

   ) , * & = - + < / > at in is mod remainder not rem
   <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
   LIKE4_ LIKEC_ between || multiset member SUBMULTISET_
The symbol "* was inserted before "CHECK" to continue.
4/1
PLS-00103: Encountered the symbol ";" when expecting one of the following:

   ) , * & = - + < / > at in is mod remainder not rem
   <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
   LIKE4_ LIKEC_ between || year DAY_ member SUBMULTISET_
The symbol ")" was substituted for ";" to continue.


http://www.orafaq.com/forum/mv/msg/190671/602949/#msg_602949

Re: object type [message #602979 is a reply to message #602977] Tue, 10 December 2013 11:32 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
when all else fails Read The Fine Manual

http://docs.oracle.com/cd/E16655_01/server.121/e17209/statements_8001.htm#SQLRF01506

PHONE_TYPE should not be used twice in same statement.
Re: object type [message #602980 is a reply to message #602979] Tue, 10 December 2013 11:42 Go to previous messageGo to next message
aravindreddy.akiti
Messages: 14
Registered: October 2013
Location: hyderabad
Junior Member
create or replace type phone_name_type as object
(phone_number number(10),
phone_type char(1) default 'R' check(phone_type in ('R','O','P'))
);
/
Warning: Type created with compilation errors.
Re: object type [message #602981 is a reply to message #602980] Tue, 10 December 2013 11:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Michel Cadot wrote on Tue, 10 December 2013 18:31

SQL> create or replace type phone_type as object
  2  (phone_number number(10),
  3  phone_type char(1) default 'R' check (phone_type in ('R','O','P'))
  4  ;
  5  /

Warning: Type created with compilation errors.

SQL> sho err
Errors for TYPE PHONE_TYPE:
LINE/COL
-------------------------------------------------------------------------------
ERROR
-------------------------------------------------------------------------------
3/32
PLS-00103: Encountered the symbol "CHECK" when expecting one of the following:

   ) , * & = - + < / > at in is mod remainder not rem
   <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
   LIKE4_ LIKEC_ between || multiset member SUBMULTISET_
The symbol "* was inserted before "CHECK" to continue.
4/1
PLS-00103: Encountered the symbol ";" when expecting one of the following:

   ) , * & = - + < / > at in is mod remainder not rem
   <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
   LIKE4_ LIKEC_ between || year DAY_ member SUBMULTISET_
The symbol ")" was substituted for ";" to continue.


http://www.orafaq.com/forum/mv/msg/190671/602949/#msg_602949


Re: object type [message #602982 is a reply to message #602980] Tue, 10 December 2013 11:45 Go to previous messageGo to next message
flyboy
Messages: 1903
Registered: November 2006
Senior Member
It seems you are trying to define the object using relational properties. This so non-object oriented!

For these OO puritans, Oracle provides TYPE for declaration (visible outside) and TYPE BODY for implementation ("encapsulation" is your favourite description of this feature).
It is documented in the book which BlackSwan posted a link (plus the next chapter for TYPE body).

Of course, working with this kind of design is quite a challenge if you try to bind it with relational world. Enjoy it!
Re: object type [message #602983 is a reply to message #602981] Tue, 10 December 2013 11:46 Go to previous messageGo to next message
aravindreddy.akiti
Messages: 14
Registered: October 2013
Location: hyderabad
Junior Member
pls solve it give the correct command
Re: object type [message #602985 is a reply to message #602983] Tue, 10 December 2013 11:51 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Please do not use something you will be unable to use.

Re: object type [message #602986 is a reply to message #602983] Tue, 10 December 2013 11:52 Go to previous messageGo to next message
ThomasG
Messages: 3211
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
aravindreddy.akiti wrote on Tue, 10 December 2013 18:46
pls solve it give the correct command


drop type phone_type;


is bound to work beautifully without producing any errors.
Re: object type [message #602988 is a reply to message #602986] Tue, 10 December 2013 12:03 Go to previous messageGo to next message
ThomasG
Messages: 3211
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Another thing why you shouldn't use Types. Let's consider you where really stupid enough to do this:

create or replace type phone_type as object
(phone_number number(10),
 phone_class char(1) 
 )
;
/

CREATE TABLE phones (col phone_type);


and next year you find you have phone numbers with 11 digits. You could change a number(10) column to a number(15) column in a table without any problem, but :

SQL> create or replace type phone_type as object
  2  (phone_number number(15),
  3   phone_class char(1)
  4   )
  5  ;
  6  /
create or replace type phone_type as object
*
ERROR at line 1:
ORA-02303: cannot drop or replace a type with type or table dependents



So FORGET about objects for now. Completely and absolutely. They have some uses in PL/SQL when you create and pass them on the fly, but NEVER EVER store them in Tables unless you are absolutely sure about about what you are doing.


Re: object type [message #602989 is a reply to message #602988] Tue, 10 December 2013 12:09 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Object Oriented Programming & Relational DataBase Management System are orthogonal concepts
Newbies especially should NEVER intermix these two disparate entities.
Re: object type [message #602996 is a reply to message #602977] Tue, 10 December 2013 12:47 Go to previous message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
How many different postings are you going to title "object type?"
Previous Topic: dbms_output.put_line
Next Topic: Accessing data from MS Access into Oracle using Oracle procedure
Goto Forum:
  


Current Time: Fri Apr 26 03:53:13 CDT 2024