|Subject||Re: [firebird-support] Test VARCAHR for numeric|
|Author||Walter R. Ojeda Valiente|
On Fri, Apr 24, 2015 at 2:53 AM, Mark Rotteveel mark@... [firebird-support] <email@example.com> wrote:
On Thu, 23 Apr 2015 20:00:32 -0400, "'Walter R. Ojeda Valiente'
> You can use SIMILAR TO, something like it:
> MyColumn1 SIMILAR TO '[[:DIGIT:]]*'
> Where just the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 are valid.
I'd also check for minus signs, and take into account the maximum number
of digits in a number (eg 10 in an INTEGER, 19 or 20 in a BIGINT), but even
then there is no guarantee (eg 2,147,483,648 doesn't fit in an INTEGER,
while 2,147,483,647 does). The only sure way is too actually attempt the
conversion and handle the exception.
> If you need the decimal point too, try something like it, where the
> decimail point is required:
> SIMILAR TO '[[:DIGIT:]]*.[[:DIGIT:]]*'
> And if you can have integers and floats (decimal point can be, but not
> required), you can try:
> SIMILAR TO '[[:DIGIT:]]*.?[[:DIGIT:]]*'
Don't forget the exponent notation (eg 5.203E-5)
> And, finally, if you can read Spanish, take a look at: