Subject Re: [firebird-support] Cast numeric(4,2) as Varchar(20) returns null string
Author Helen Borrie
At 11:13 PM 7/06/2008, you wrote:
>Hi,
>
>if X is defined as follows:
>declare variable X numeric(4,2);
> or
>declare variable X numeric(9,4);
>
>
>Why is it that CAST(X AS VARCHAR(20)) returns a NULL string? (for
>instance X = 5.5, the CAST function returns a NULL string)

CAST() needs a value to operate on. If you declare a variable, it is null until a value is assigned to it. Null is not a value, it is a state. There is no such thing as "a null string". CAST(NULL AS VARCHAR(20)) returns null.

If, for example, you declared as follows (as you can):

declare variable x numeric(9,4) = 5.5;
declare variable xv varchar(20);
...
..
xv = CAST(X AS VARCHAR(20))

you should get '5.5000' returned.

./heLen