Subject | Re: [firebird-support] Test VARCAHR for numeric |
---|---|
Author | Walter R. Ojeda Valiente |
Post date | 2015-04-24T00:00:32Z |
You can use SIMILAR TO, something like it:
SELECT
MyColumn1,
MyColumn2,,
MyColumn3
FROM
MyTable
WHERE
MyColumn1 SIMILAR TO '[[:DIGIT:]]*'
Where just the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 are valid.
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:]]*'
And, finally, if you can read Spanish, take a look at:
Greetings.
Walter.
On Thu, Apr 23, 2015 at 2:34 PM, sboydlns@... [firebird-support] <firebird-support@yahoogroups.com> wrote:Is there any way, within a stored procedure, to test a VARCHAR to see if it contains a valid number? I have a parameter that can contain different types of value and it would be nice to be able to know if CAST(param as BIGINT) is going to fail before an exception is thrown.