-
-
Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathREADME.trim
48 lines (38 loc) · 1.38 KB
/
README.trim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
SQL Language Extension: TRIM
Function:
Remove leading, trailing or both substring from a string.
Author:
Adriano dos Santos Fernandes <adrianosf@uol.com.br>
Format:
<trim function> ::=
TRIM <left paren> [ [ <trim specification> ] [ <trim character> ] FROM ] <value expression> <right paren>
<trim specification> ::=
LEADING
| TRAILING
| BOTH
<trim character> ::=
<value expression>
<multi-character trim function> ::=
{ BTRIM | LTRIM | RTRIM } <left paren> <value expression> [ <comma> <trim character> ] <right paren>
Syntax Rules:
1) If <trim specification> is not specified, BOTH is assumed.
2) If <trim character> is not specified, ' ' is assumed.
3) If <trim specification> and/or <trim character> is specified, FROM should be specified.
4) If <trim specification> and <trim character> is not specified, FROM should not be specified.
5) multi-character trim function accepts a sequence of characters as the second argument and will remove all
leading, trailing, or both occurrences of any of these characters, regardless of their ordering.
Examples:
A)
select
rdb$relation_name, trim(leading 'RDB$' from rdb$relation_name)
from rdb$relations
where rdb$relation_name starting with 'RDB$';
B)
select
trim(rdb$relation_name) || ' is a system table'
from rdb$relations
where rdb$system_flag = 1;
C)
select
ltrim('baobab is a tree', 'aboe')
from rdb$database;