Subject | RE: [firebird-support] Re: Domain definition |
---|---|
Author | Rick Debay |
Post date | 2006-01-06T17:27:05Z |
Some real-life examples:
/* eleven digit number (National Drug Code) */
CREATE DOMAIN D_NDC AS
NUMERIC(11,0)
CHECK ((VALUE IS NULL) OR (VALUE BETWEEN 0 AND +99999999999))
;
/* ten character field that must be a number (Therapeutic Classification
Code) */
CREATE DOMAIN D_MDDB_TCC AS
CHAR(10)
CHECK (VALUE IS NULL OR
(
(strlen(ltrim(rtrim(VALUE))) = 10) AND
/* first 10 digits are numeric */
(CAST (('1' || VALUE) AS NUMERIC(11,0)) BETWEEN 10000000000 AND
19999999999 AND VALUE NOT CONTAINING 'e')
))
COLLATE ISO8859_1;
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Daniel R. Jimenez
Sent: Friday, January 06, 2006 12:07 AM
To: firebird-support@yahoogroups.com
Subject: RE: [firebird-support] Re: Domain definition
Not quite what I had in mind.
Correction I had nothing in mind, thus the question.
Definitely outsize the square :-)
Thanks
Daniel
/* eleven digit number (National Drug Code) */
CREATE DOMAIN D_NDC AS
NUMERIC(11,0)
CHECK ((VALUE IS NULL) OR (VALUE BETWEEN 0 AND +99999999999))
;
/* ten character field that must be a number (Therapeutic Classification
Code) */
CREATE DOMAIN D_MDDB_TCC AS
CHAR(10)
CHECK (VALUE IS NULL OR
(
(strlen(ltrim(rtrim(VALUE))) = 10) AND
/* first 10 digits are numeric */
(CAST (('1' || VALUE) AS NUMERIC(11,0)) BETWEEN 10000000000 AND
19999999999 AND VALUE NOT CONTAINING 'e')
))
COLLATE ISO8859_1;
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Daniel R. Jimenez
Sent: Friday, January 06, 2006 12:07 AM
To: firebird-support@yahoogroups.com
Subject: RE: [firebird-support] Re: Domain definition
> > Hi,Hi Adam,
> >
> > Is it possible to have a domain definition for a field in a table
> where the
> > field is an integer of a set length?
> >
> > For example the data must contain 11 digits such as 20051225906
> >
> > Thank you
> >
> > Daniel
> >
>
> Yes,
>
> Use Check between 10000000000 and 99999999999
>
> Of course I am assuming it is unacceptable to have a number with fewer
> digits then 11, or with padded zeroes on the left.
>
> Adam
>
Not quite what I had in mind.
Correction I had nothing in mind, thus the question.
Definitely outsize the square :-)
Thanks
Daniel