Products Downloads


French version


 

 

Syntax

LEFT(String,Length)

 

Description

The LEFT SQL scalar function returns the leftmost specified number of characters from the string.

 

The result is a character string.

If any argument of the LEFT function can be null, the result can be null; if any argument is null, the result is the null value.

 

Parameters

string

Denotes an argument that specifies the string from which the result is derived.

String must be a character string.

A substring of string is zero or more contiguous bytes of string.

 

length

Denotes an argument that specifies the length of the result. Length must be a binary integer in the range 0 to n, where n is the length attribute of string. It must not, however, be the integer constant 0.

 

The string is effectively padded on the right with the necessary number of blank characters so that the specified substring of string always exists.

 

If length is specified by an integer constant, the result is a fixed-length string. In all other cases, the result is a varying-length string with a length attribute that is the same as the length attribute of string. A sourced function based on LEFT will always have a result that is a varying-length string.

 

Example

Assume the host variable NAME (ALPHA(50)) has a value of 'KATIE AUSTIN' and the host variable FIRSTNAME_LEN (NUM_BIN_4) has a value of 5.

 

LEFT(:NAME, :FIRSTNAME_LEN)

 

Returns the value 'KATIE'.

 

List of SQL scalar functions by topic

 

↑ Top of page

  • Aucune étiquette