Subject Re: Type conversions in stored procedures
Author Adam
--- In firebird-support@yahoogroups.com, <firebird@...> wrote:
>
> Is there a way I can test an input parameter (of type varchar) in a
stored
> procedure to see if it's a legal number? Also, how can I convert
back and
> forth between numbers and strings within a stored procedure?


Just use Cast. You will get an exception if it is not valid, and you
can capture and otherwise handle this exception if you want.

SomeInt = Cast(MyVarcharField as Integer);

and

SomeVarcharField = Cast(SomeInt as Varchar(20));

You need to make sure that the integer type is large enough to handle
the largest input number (might need BigInt), and you will need to
make sure the varchar is large enough to handle whatever integer is
converted.

Adam