CONVERT function (extension)
Syntax
CONVERT ( { 'data_type[(length)]' | data_type[(length)] }, expression )
Description
The scalar function CONVERT converts an expression to another data type. The first argument is the target data type. The second argument is the expression to be converted to that type.
As indicated in the syntax, single quotes surrounding the data type are optional.
The length option for the data_type argument specifies the length for conversions to character types. If omitted, the default length is 30.
If the expression evaluates to null, the result of the function is null.
The CONVERT function syntax is similar to but not compatible with the ODBC CONVERT function. Enclose the function in the ODBC escape clause {fn }, to specify ODBC-compliant syntax. See CONVERT function (ODBC compatible) for more information.
Examples
The following FairCom DB SQL examples convert an integer field from a catalog table to a character string:
SELECT CONVERT('CHAR', fld), fld FROM admin.syscalctable;
CONVERT(CHAR,FLD) FLD
----------------- ---
100 100
1 record selected
SELECT CONVERT('CHAR(35)', fld), fld
FROM admin.syscalctable;
CONVERT(CHAR(35),FLD) FLD
--------------------- ---
100 100
1 record selected
SELECT CONVERT(CHAR(50), fld), fld FROM systpe.syscalctable;
CONVERT(CHARACTER,FLD) FLD
---------------------- ---
100 100
1 record selected