Application Note for QuNect ODBC for QuickBase

Scalar String Functions Supported by QuNect ODBC for QuickBase

Arguments denoted as string_exp can be the name of a column, a character-string-literal, or the result of another scalar function, where the underlying data type can be represented as SQL_CHAR, SQL_VARCHAR, or SQL_LONGVARCHAR.

Arguments denoted as character_exp are a variable-length character string.

Arguments denoted as start, length, or count can be a numeric-literal or the result of another scalar function, where the underlying data type can be represented as SQL_TINYINT, SQL_SMALLINT, or SQL_INTEGER.

The string functions listed here are 1-based; that is, the first character in the string is character 1.

The BIT_LENGTH, CHAR_LENGTH, CHARACTER_LENGTH, OCTET_LENGTH, and POSITION string scalar functions have been added in ODBC 3.0 to align with SQL-92.

Function Description
{fn ASCII(string_exp)}
Returns the ASCII code value of the leftmost character of string_exp as an integer.
{fn BIT_LENGTH(string_exp)}
Returns the length in bits of the string expression.
{fn CHAR(code)}
Returns the character that has the ASCII code value specified by code. The value of code should be between 0 and 255; otherwise, the return value is data source–dependent.
{fn CHAR_LENGTH(string_exp)}
Returns the length in characters of the string expression, if the string expression is of a character data type; otherwise, returns the length in bytes of the string expression (the smallest integer not less than the number of bits divided by 8). (This function is the same as the CHARACTER_LENGTH function.)
{fn CHARACTER_LENGTH(string_exp)}
Returns the length in characters of the string expression, if the string expression is of a character data type; otherwise, returns the length in bytes of the string expression (the smallest integer not less than the number of bits divided by 8). (This function is the same as the CHAR_LENGTH function.)
{fn CONCAT(string_exp1, string_exp2)}
Returns a character string that is the result of concatenating string_exp2 to string_exp1. The resulting string is DBMS-dependent. For example, if the column represented by string_exp1 contained a NULL value, DB2 would return NULL but SQL Server would return the non-NULL string.
{fn DIFFERENCE(string_exp1, string_exp2)}
Returns an integer value that indicates the difference between the values returned by the SOUNDEX function for string_exp1 and string_exp2.
{fn INSERT(string_exp1, start, length, string_exp2)}
Returns a character string where length characters have been deleted from string_exp1, beginning at start, and where string_exp2 has been inserted into string_exp, beginning at start.
{fn LCASE(string_exp)}
Returns a string equal to that in string_exp, with all uppercase characters converted to lowercase.
{fn LEFT(string_exp, count)}
Returns the leftmost count characters of string_exp.
{fn LENGTH(string_exp)}
Returns the number of characters in string_exp, excluding trailing blanks.
{fn LOCATE(string_exp1, string_exp2[, start])}
Returns the starting position of the first occurrence of string_exp1 within string_exp2. The search for the first occurrence of string_exp1 begins with the first character position in string_exp2 unless the optional argument, start, is specified. If start is specified, the search begins with the character position indicated by the value of start. The first character position in string_exp2 is indicated by the value 1. If string_exp1 is not found within string_exp2, the value 0 is returned.

If an application can call the LOCATE scalar function with the string_exp1, string_exp2, and start arguments, the driver returns SQL_FN_STR_LOCATE when SQLGetInfo is called with an Option of SQL_STRING_FUNCTIONS. If the application can call the LOCATE scalar function with only the string_exp1 and string_exp2 arguments, the driver returns SQL_FN_STR_LOCATE_2 when SQLGetInfo is called with an Option of SQL_STRING_FUNCTIONS. Drivers that support calling the LOCATE function with either two or three arguments return both SQL_FN_STR_LOCATE and SQL_FN_STR_LOCATE_2.

{fn LTRIM(string_exp)}
Returns the characters of string_exp, with leading blanks removed.
{fn OCTET_LENGTH(string_exp)}
Returns the length in bytes of the string expression. The result is the smallest integer not less than the number of bits divided by 8.
{fn POSITION(character_exp IN character_exp)}
Returns the position of the first character expression in the second character expression. The result is an exact numeric with an implementation-defined precision and a scale of 0.
{fn REPEAT(string_exp, count)}
Returns a character string composed of string_exp repeated count times.
{fn REPLACE(string_exp1, string_exp2, string_exp3)}
Search string_exp1 for occurrences of string_exp2, and replace with string_exp3.
{fn RIGHT(string_exp, count)}
Returns the rightmost count characters of string_exp.
{fn RTRIM(string_exp)}
Returns the characters of string_exp with trailing blanks removed.
{fn SOUNDEX(string_exp)}
Returns a data source–dependent character string representing the sound of the words in string_exp. For example, SQL Server returns a 4-digit SOUNDEX code; Oracle returns a phonetic representation of each word.
{fn SPACE(count)} Returns a character string consisting of count spaces.
{fn SUBSTRING(string_exp, start, length)}
Returns a character string that is derived from string_exp, beginning at the character position specified by start for length characters.
{fn UCASE(string_exp)}
Returns a string equal to that in string_exp, with all lowercase characters converted to uppercase.