Str2real

sql

FUNCTION Str2real(IN s CHAR(n)) RETURNS REAL

Parameters

s character string containing a Real type number notation

Description

The real function converts the number notation in the s string into the real type value and returns that value. Empty string will be converted into NULL. You may also the similar CAST SQL function.

The string may be in decimal or semialgorithmic notation, wich decimal and thousand separator according to the national (local) setting (locales on Linux) or with the decimal dot and blank space as thousand separator.

Function value

This function returns the real numeric value if the string contains a convertable notation of the Real type number. Otherwise NULL is returned.

Examples of strings that can be converted

SET str = '1.234';
SET str = '-100';
SET str = '1 234,567'; // in the Windows CZ local coding
SET str = '1.2e5';
SET str = '1.'

Examples of strings that cannot be converted

SET str := '1.234Kč';
SET str ='10,-';
SET str = '$100';
SET str ='1$10';

See