Click to See Complete Forum and Search --> : Val like function


German Turriziani
04-26-2001, 04:19 PM
Hi All:
Anybody knows if informix dynamic server workgroup edition 7.30 has a function
like Visual Basic VAL() ?

Dimitar Dimitrov
05-09-2001, 04:29 AM
"German Turriziani" <gturriziani@tutopia.com> wrote:
>
>Hi All:
>Anybody knows if informix dynamic server workgroup edition 7.30 has a function
>like Visual Basic VAL() ?

There isn't such a function like VAL() in Informix Dynamic Server. But you
can create and use a stored procedure that covers functionality of VAL().
Here is a simple source code :

create procedure IfxVal( pVarChar varchar(255)) returning decimal(32,3);

define lDec decimal(32,3);

let lDec = pVarChar;
return lDec;

end procedure;

Of course, you may change the data type of returned value with integer, float,
etc., specificaly to your needs. Don't forget to change the data type of
inner variable lDec accordingly to returning data type.
Thus created procedure may use in aggregate expressions (like SUM, AVG, etc.)
in this way :
select SUM( IfxVal( some_string_column)) from your_table;

Regards,
Dimitar

German Turriziani
05-09-2001, 08:45 AM
Thank you Dimitar your example was very valuable for me. Thanks again.

Germán Turriziani