Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

SUFFIX function (extension)

Syntax

SUFFIX(char_expression1, start_position, char_expression2)

Description

The scalar function SUFFIX returns the substring of a character string starting after the position specified by start_position and the second char_expression, to the end of the string.

Arguments

char_expression1

An expression that evaluates to a character string, typically a character-string literal or column name. If the expression evaluates to null, SUFFIX returns null.

start_position

An expression that evaluates to an integer value. SUFFIX searches the string specified in the first argument starting at that position. A value of one indicates the first character of the string.

char_expression2

An expression that evaluates to a single character. SUFFIX returns the substring that begins with that character. If SUFFIX does not find the character after start_position, it returns null. If the expression evaluates to more than one character, SUFFIX ignores all but the first character.

Example

SELECT C1, C2, SUFFIX(C1, 6, '.') FROM T1;

C1 C2 SUFFIX(C1,6,.

-- -- -------------

test.pref .

pref.test s

2 records selected

SELECT C1, C2, SUFFIX(C1, 1, C2) FROM T1;

C1 C2 SUFFIX(C1,1,C

-- -- -------------

test.pref . pref

pref.test s t

2 records selected

SELECT C1, C2, SUFFIX(C1, 6, '.') FROM T1;

C1 C2 SUFFIX(C1,6,.

-- -- -------------

test.pref .

pref.test s

2 records selected

NOTES

  • If one of the arguments is a literal and the other one a field reference, the operation is possible only if the literal is convertible to the character set of the field reference. Otherwise an error is returned.

TOCIndex