Subject Re: [firebird-support] Cast SQL
Author Martijn Tonies
Hi James,

> I have a sql statement like this
>
> select checkno, cast(checkno as bigint)
> from payment
>
> My problem is that some value in checkno contains non numeric
> characters. how can I tell the Firebird to skip those records which
> contains non numeric charaters in order to prevent the avobe sql
> statement to give error message?

The best thing I can think of is something like this:

create procedure docast (checkno <checkno datatype>) returns (checkno_int
bigint)
as
begin
begin
checkno_int = cast(checkno as bigint);
when all do checkno_int = 0;
end
suspend;
end

and then:

select checkno, (select checkno_int from docast(checkno))
from payment

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com