Function support of LONG VARCHAR data type

The functions BIT_LENGTH, OCTET_LENGTH, CHAR_LENGTH64, SUBSTRING64, CHAR_LENGTH and SUBSTRING support LONG VARCHAR data.

The LONG BINARY functions BYTE_LENGTH64, BYTE_SUBSTR64, and BYTE_SUBSTR also support LONG VARCHAR data.

See “CHAR_LENGTH function [String]” and “SUBSTRING function [String]” in Chapter 5, “SQL Functions” of the Sybase IQ Reference Manual for descriptions of the CHAR_LENGTH and SUBSTRING functions.

BIT_LENGTH function

The BIT_LENGTH function returns an unsigned 64 bit value containing the bit length of the LONG VARCHAR column parameter. If the argument is NULL, BIT_LENGTH returns NULL.

Syntax:

BIT_LENGTH( column-name )

Parameter:

column-name The name of a LONG VARCHAR column.

The BIT_LENGTH function supports all Sybase IQ data types.

OCTET_LENGTH function

The OCTET_LENGTH function returns an unsigned 64 bit value containing the byte length of the LONG VARCHAR column parameter. If the argument is NULL, OCTET_LENGTH returns NULL.

Syntax:

OCTET_LENGTH( column-name )

Parameter:

column-name The name of a LONG VARCHAR column.

The OCTET_LENGTH function supports all Sybase IQ data types.

CHAR_LENGTH function

The CHAR_LENGTH function returns a signed 32 bit value containing the character length of the LONG VARCHAR column parameter, including the trailing blanks. If the argument is NULL, CHAR_LENGTH returns NULL. If the character length exceeds 2147483647, an error is returned.

Syntax:

CHAR_LENGTH( long-varchar-column )

Parameter:

long-varchar-column The name of a LONG VARCHAR column.

CHAR_LENGTH64 function

The CHAR_LENGTH64 function returns an unsigned 64 bit value containing the character length of the LONG VARCHAR column parameter, including the trailing blanks. If the argument is NULL, CHAR_LENGTH64 returns NULL.

Syntax:

CHAR_LENGTH64( long-varchar-column )

Parameter:

long-varchar-column The name of a LONG VARCHAR column.

SUBSTRING function

The SUBSTRING function returns a variable length character string of the LONG VARCHAR column parameter. If any of the arguments are NULL, SUBSTRING returns NULL.

Syntax:

SUBSTRING( long-varchar-column, start [ , length ] )

Parameters:

long-varchar-column The name of a LONG VARCHAR column.

start An integer expression indicating the start of the substring. A positive integer starts from the beginning of the string, with the first character at position 1. A negative integer specifies a substring starting from the end of the string, with the final character at position -1.

length An integer expression indicating the character length of the substring. A positive length specifies the number of characters to return, starting at the start position. A negative length specifies the number of characters to return, ending at the start position.

SUBSTRING64 function

The SUBSTRING64 function returns a variable length character string of the LONG VARCHAR column parameter. If any of the arguments are NULL, SUBSTRING64 returns NULL.

Syntax:

SUBSTRING64( large-object-column, start [ , length ] )

Parameters:

large-object-column The name of a LONG VARCHAR column.

start An 8 byte integer indicating the start of the substring. SUBSTRING64 interprets a negative or zero start offset as if the string were padded on the left with “non-characters.” The first character starts at position 1.

length An 8 byte integer indicating the length of the substring. If length is negative, an error is returned.

For example, given a column named col1 which contains the string (‘ABCDEFG’), the SUBSTRING64 function returns the following values:

SUBSTRING64( col1, 2, 4 ) returns the string ‘BCDE’

SUBSTRING64( col1, 1, 3 ) returns the string ‘ABC’

SUBSTRING64( col1, 0, 3 ) returns the string ‘AB’

SUBSTRING64( col1, -1, 3 ) returns the string ‘A’

The SUBSTRING64 function also supports the LONG BINARY data type.

Nesting of the functions SUBSTRING64, SUBSTRING, BYTE_SUBSTR, and BYTE_SUBSTR64 is not supported.

Aggregate functions

Only the aggregate function COUNT (*) is supported for LONG VARCHAR columns. The COUNT DISTINCT parameter is not supported. An error is returned if a LONG VARCHAR column is used with the MIN, MAX, AVG, or SUM aggregate functions.