CREATE OR ALTER function FN_EXECUTE_CALC_V3 (
    CALC varchar(7000))
returns numeric(18,6)
AS
BEGIN
    CALC = trim(coalesce(CALC,'0'));
    CALC = iif(CALC = '', '0', CALC);

    EXECUTE STATEMENT 'SELECT FIRST 1 FN_NUMBER_TRIM(' || CALC || ') FROM RDB$DATABASE' INTO CALC;
    RETURN CALC;

    WHEN ANY DO
      BEGIN
         return 0;
      END
END;

