Gerhard Wolf asked:

is there a way to convert a string to a number in a where clause without error? for example:

select * fromd data where cast(sn as integer) > 1000;

I tried to replace it with and some others...

select * from daten where (case when sn similar to '[0-9]+'
then cast (sn as integer) else null end ) > 0;

but it still reports error on first non number string.

Svein Erling Tysvær answers:

I tried something very similar to

select * from daten where (case when sn similar to '[0-9]+'
then cast (sn as integer) else null end ) > 0

and it worked in Firebird 2.5.

Though I might have considered rewriting it

select * from daten where cast(iif(sn similar to '[[:DIGIT:]]+', sn, null) as integer) > 0

Mark Rotteveel adds:

Or use a Firebird 3 Function.

Like this post? Share on: TwitterFacebookEmail


Related Articles


Author

Firebird Community

Published

Category

Gems from Firebird Support list

Tags