SUBSTRING Function [String]

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

Syntax

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

Parameters

long-varchar-column – the name of a LONG VARCHAR column or variable.

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.

Usage

SUBSTRING supports LONG VARCHAR variables of any size of data. Currently, a SQL variable can hold up to 2GB - 1 in length. SUBSTRING does not support LONG BINARY variables or searching LONG BINARY columns.

When the ansi_substring database option is set to ON (default), negative values are invalid.