Contents Index BYTE_LENGTH function [String] CAST function [Data type conversion]

ASA SQL Reference
  SQL Functions
    Alphabetical list of functions

BYTE_SUBSTR function [String]


Function 

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

Syntax 

BYTE_SUBSTR ( string-expressionstart  [, 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 specifies the number of bytes to be taken ending at the start position.

Usage 

If length is specified, the substring is restricted to that number of bytes. Both start and length can be either positive or negative. A negative starting position specifies a number of bytes from the end of the string instead of the beginning. A positive length specifies that the substring ends length bytes to the right of the starting position, while a negative length specifies that the substring ends length bytes to the left of the starting position and ends at the start position. Using appropriate combinations of negative and positive numbers, you can get a substring from either the beginning or end of the string.

Standards and compatibility 
See also 

SUBSTRING function [String]

Example 

The following statement returns the value age .

SELECT BYTE_SUBSTR( 'Test Message',-1,-3 )

Contents Index BYTE_LENGTH function [String] CAST function [Data type conversion]