Skip to Main Content

Oracle Database Free

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL Domain vs PL/SQL Subtype

Mike KutzAug 27 2023

As a developer, i would like to use the power of SQL Domains for use by my PL/SQL data types so that I can write code that is resilient to GIGO.

The available data assertion:

subtype die_t as pls_integer range 1 .. 6 not null;

only works for pls_integer data types where as the following doesn't work for pls_integer data types at all

create domain die_dom as int not null check ( die_dom between 1 and 6 );

However, both assert the same data rules (a not null integer between 1 and 6)

SUGGESTED SYNTAX

Type based on an existing domain:

subtype die_t as domain die_dom;

Ad Hoc version:

subtype die_t as int not null check ( die_t between 1 and 6 );

For multi-column & flexible domains:

type rec_t is record ( ...., domain dom_name(..) );
type rec_f is record ( ...., domain dom_name(..) using (..) );
This post has been answered by Chris Saxon-Oracle on Aug 30 2023
Jump to Answer
Comments
Post Details
Added on Aug 27 2023
13 comments
715 views