Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Seeking Equivalent of InterBase Domain
MRCarver wrote:
> Daniel,
>
> Thanks again for the attention !
>
> Can one further define the TYPE with a constraint? Something like:
>
> CREATE OR REPLACE TYPE Bool_DOM OBJECT (
> Bool_DOM VARCHAR2(1) with CONSTRAINT BoolChk ((Bool_DOM IN('Y', 'N"))
> );
I hadn't come across Interbase or its Domain feature before but it sounds like quite a nice idea. Oracle doesn't have anything like this. I don't think object types are close, as they are not scalar and can't include constraints. If you used the above BOOL_DOM object type for a table column you would have to repeat the attribute name (in your example, 'bool_dom') everywhere using dot notation:
SELECT e.empno, e.ename, e.is_director.bool_dom FROM employees;
and use constructor syntax to set its value:
INSERT INTO employees (is_director) VALUES (BOOL_DOM('Y'));
Also queries would return the complex object rather than a scalar.
This would not give you any of the benefits you are after.
btw CHAR sucks, and I would personally avoid it even for fixed-length columns such as mandatory indicators. Received on Sat Jan 20 2007 - 09:21:56 CST
![]() |
![]() |