Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » UltraLite - Database Management and Reference » UltraLite SQL Function Reference » Alphabetical list of functions

BYTE_LENGTH function [String] Next Page

BYTE_SUBSTR function [String]


Returns a substring of a string. The substring is calculated using bytes, not characters.

Syntax

BYTE_SUBSTR( string-expression, start [, length ] )

Parameters

string-expression    The string from which the substring is taken.

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

length    An integer expression indicating the length of the substring. A positive length specifies the number of bytes to be taken starting at the start position. A negative length returns at most length bytes up to, and including, the starting position, from the left of the starting position.

Remarks

If length is specified, the substring is restricted to that number of bytes. Both start and length can be either positive or negative. Using appropriate combinations of negative and positive numbers, you can get a substring from either the beginning or end of the string.

If start is zero and length is non-negative, a start value of 1 is used. If start is zero and length is negative, a start value of -1 is used.

See also
Standards and compatibility
Example

The following statement returns the value Test.

SELECT BYTE_SUBSTR( 'Test Message', 1, 4 );