object type [message #602977] |
Tue, 10 December 2013 11:27 |
|
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 #602982 is a reply to message #602980] |
Tue, 10 December 2013 11:45 |
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 #602986 is a reply to message #602983] |
Tue, 10 December 2013 11:52 |
ThomasG
Messages: 3211 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
aravindreddy.akiti wrote on Tue, 10 December 2013 18:46pls solve it give the correct command
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 |
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.
|
|
|
|
|