Skip to main content
Scalar function
Aliases: substring NULL arguments return NULL. Position 0 starts at the beginning. Nonpositive length returns an empty value. Strings count characters; binary values count bytes.

Syntax

To end (scalar)

Scalar

Arguments

To end

Scalar

Returns

  • Type: STRING or BINARY
  • NULL behavior: NULL arguments return NULL. Position 0 starts at the beginning. Nonpositive length returns an empty value. Strings count characters; binary values count bytes.

Properties

Units

  • Input unit: Characters for STRING; bytes for BINARY.
  • Output unit: Characters for STRING; bytes for BINARY.
  • Omitting length reads through the end. Positions past the available input produce an empty value.

Usage notes

  • Position and length are ordinary arguments. Neither is a pre-call configuration parameter or required to be a constant.
  • The two-argument form has no length argument; it reads through the end instead of substituting a numeric default.

Examples

Substring with a length limit

Omitted length

Negative and zero positions

Empty results

NULL input

Binary positions count bytes

Non-integer position is rejected

  • The explicit DOUBLE cast demonstrates the integer-argument restriction.
Expected error: Unsupported position or length type

Limitations

  • Use integer positions and lengths. Other numeric types and STRING values are outside these calling forms.
Last modified on October 15, 2026