Scalar Functions
This section lists the scalar functions that ODBC supports. Your database system may not support all these functions. Refer to the documentation for your database system to find out which functions are supported. Also, depending on the driver that you are using, all the scalar functions may not be supported. To check which scalar functions are supported by a driver, use the SQLGetInfo ODBC function.
You can use these scalar functions in SQL statements using the following syntax:
where
scalar-functionis one of the functions listed in Table 2-3 through Table 2-6. For example:String Functions
Table 2-3 lists the string functions that ODBC supports.
The string functions listed accept the following arguments:
string_expcan be the name of a column, a string literal, or the result of another scalar function, where the underlying data type is SQL_CHAR, SQL_VARCHAR, or SQL_LONGVARCHAR.start,length, andcountcan be the result of another scalar function or a literal numeric value, where the underlying data type is SQL_TINYINT, SQL_SMALLINT, or SQL_INTEGER.The string functions are one-based; that is, the first character in the string is character 1.
Character string literals must be surrounded in single quotation marks.
Numeric Functions
Table 2-4 lists the numeric functions that ODBC supports.
The numeric functions listed accept the following arguments:
- numeric_exp can be a column name, a numeric literal, or the result of another scalar function, where the underlying data type is SQL_NUMERIC, SQL_DECIMAL, SQL_TINYINT, SQL_SMALLINT, SQL_INTEGER, SQL_BIGINT, SQL_FLOAT, SQL_REAL, or SQL_DOUBLE.
- float_exp can be a column name, a numeric literal, or the result of another scalar function, where the underlying data type is SQL_FLOAT.
- integer_exp can be a column name, a numeric literal, or the result of another scalar function, where the underlying data type is SQL_TINYINT, SQL_SMALLINT, SQL_INTEGER, or SQL_BIGINT.
Date and Time Functions
Table 2-5 lists the date and time functions that ODBC supports.
The date and time functions listed accept the following arguments:
- date_exp can be a column name, a date or timestamp literal, or the result of another scalar function, where the underlying data type can be represented as SQL_CHAR, SQL_VARCHAR, SQL_DATE, or SQL_TIMESTAMP.
- time_exp can be a column name, a timestamp or timestamp literal, or the result of another scalar function, where the underlying data type can be represented as SQL_CHAR, SQL_VARCHAR, SQL_TIME, or SQL_TIMESTAMP.
- timestamp_exp can be a column name; a time, date, or timestamp literal; or the result of another scalar function, where the underlying data type can be represented as SQL_CHAR, SQL_VARCHAR, SQL_TIME, SQL_DATE, or SQL_TIMESTAMP.
System Functions
Table 2-6 lists the system functions that ODBC supports.