Subject Re: [firebird-support] CHECK for all numeric characters
Author David Johnson
On Thu, 2005-09-01 at 18:26 +0200, Ivan Prenosil wrote:
> > I'm creating a domain that's CHAR(11) and I'd like to add a check to
> > make sure all the characters are numeric. I'm experiencing a brain
> > freeze right now and can't come up with one. Can anyone suggest the
> > appropriate CHECK statement(s)?
>
> CHECK (Value BETWEEN '00000000000' AND '99999999999')
>
> Ivan
>
>

Not quite ... this will allow '0A'.

I have recently had to coerce some character columns with garbage data
into numerics in another SQL dialect. I believe that there are UDF's
that will do this task:

length(rtrim(transform(column, '0123456789', ' '))) = 0