Subject | Re: Type conversions in stored procedures |
---|---|
Author | Adam |
Post date | 2006-07-23T23:17:49Z |
--- In firebird-support@yahoogroups.com, <firebird@...> wrote:
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
>stored
> Is there a way I can test an input parameter (of type varchar) in a
> procedure to see if it's a legal number? Also, how can I convertback 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