ALLBASE/SQL Reference Manual (36216-90216)

254 Chapter8
Expressions
String Functions
function, except that the syntax is slightly different.
Syntax
[INST (
stringexpr1
,
stringexpr2
[,
n
[,
m
]])]
LTRIM
LTRIM function trims the characters specified in
charset
from the beginning of the string
stringexpr
.
Syntax
[LTRIM (
charset
,
stringexpr
)]
RTRIM
RTRIM function trims the characters specified in
charset
from the end of the string
stringexpr
.
Syntax
[RTRIM (
charset
,
stringexpr
)]
TRIM
TRIM function allows you to strip the characters specified in
charset
from the beginning
and/or the end of the string
stringexpr
.If
charset
is not specified, then blank characters
would be stripped from
stringexpr
.
Syntax
[ TRIM ({ LEADING | TRAILING | BOTH} (,
charset
,
stringexpr
)]
Examples:
Example 1
SELECT LOWER (OWNER) || '.' || LOWER (NAME)
FROM SYSTEM.TABLE
WHERE NAME = UPPER ('vendors');
Returns "purchdb .vendors "
Example 2
SELECT POSITION ('world', 'hello world')
FROM SYSTEM.TABLE
WHERE NAME = UPPER('vendors');
Returns the numeric value 7
Example 3
SELECT INSTR ('hello world hello world', 'world', 5, 2)
FROM SYSTEM.TABLE
WHERE NAME = UPPER('vendors');
Returns the numeric value 18 (starting position of the second occurrence of the string
'world').