Skip to content

Commit 87d15f5

Browse files
committed
Improve UNLIST docs
* Corrected syntax error (removed , before (data) type conversion) * Changed syntax rule names to be more in line with convention in langref * Replaced fancy single quotes with single quotes * Added linebreaks at 120 characters
1 parent f1b452e commit 87d15f5

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

doc/sql.extensions/README.unlist

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
11
SQL Language Extension: UNLIST
22

33
Function:
4-
The function parses the input string using the specified delimiter (comma "," is implied by default) and returns the identified substrings as discrete records containing a single field. Additionally, the desired type of the returned field can be specified. If the specified data type conversion is impossible, an error is raised at runtime.
4+
The function splits the input string by the specified separator (comma "," is used by default) and returns
5+
the identified substrings as discrete rows with a single column. Additionally, the desired type of the returned
6+
field can be specified. If the specified data type conversion is not possible, an error is raised at runtime.
57

68
Author:
79
Chudaykin Alex <chudaykinalex@gmail.com>
810

911
Format
10-
<table value function> ::=
11-
UNLIST ( <input> [, <separator>] [, <data type conversion>] ) [AS] <correlation name> [ ( <derived column name> ) ]
12+
<unlist> ::=
13+
UNLIST ( <input> [, <separator>] [<type-conversion>] )
14+
[AS] <correlation-name> [ ( <column-name> ) ]
1215

13-
<input> ::= <value>
16+
<input> ::= <value>
1417

15-
<separator> ::= <value>
18+
<separator> ::= <value>
1619

17-
<data type conversion> ::= RETURNING <data type>
20+
<type-conversion> ::= RETURNING <data type>
1821

1922
Syntax Rules:
2023

21-
1) <input>: any value expression that returns a string/blob of characters (or may be converted to a string), including string literals, table columns, constants, variables, expressions, etc. This parameter is mandatory.
22-
2) <separator>: optional value expression that returns a string which is used as a delimiter (i.e. it separates one value from another inside the input string). It may also be a BLOB TEXT value, limited to 32KB. If an empty string is specified, the output will be just one record containing the input string. If omitted, the comma character is used as a delimiter.
23-
2) <data type>: target data type to convert the output values into. Alternatively, a domain can be specified as the returned type. If omitted, VARCHAR(32) is implied. Feel free to suggest any better alternative default.
24-
3) <correlation name>: alias of the record set returned by the UNLIST function. It is a mandatory parameter (per SQL standard).
25-
4) <derived column name>: optional alias of the column returned by the UNLIST function. If omitted, UNLIST is used as an alias.
24+
1) <input>: any value expression that returns a string/blob of characters (or may be converted to a string), including
25+
string literals, table columns, constants, variables, expressions, etc. This parameter is mandatory.
26+
2) <separator>: optional value expression that returns a string which is used as a delimiter (i.e. it separates one
27+
value from another inside the input string). It may also be a BLOB TEXT value, limited to 32KB. If an empty string is
28+
specified, the output will be just one record containing the input string. If omitted, the comma character is used as
29+
a delimiter.
30+
2) <data type>: target data type to convert the output values into. Alternatively, a domain can be specified as
31+
the returned type. If omitted, VARCHAR(32) is implied. Feel free to suggest any better alternative default.
32+
3) <correlation name>: alias of the record set returned by the UNLIST function. It is a mandatory parameter.
33+
4) <derived column name>: optional alias of the column returned by the UNLIST function. If omitted, UNLIST is used as
34+
an alias.
2635

2736
Example:
2837
A)
@@ -32,13 +41,13 @@ B)
3241
SELECT * FROM UNLIST('100:200:300:400:500', ':' RETURNING INT) AS U;
3342

3443
C)
35-
SELECT U.* FROM UNLIST(text1, text2, text3) AS U;
44+
SELECT U.* FROM UNLIST('text1, text2, text3') AS U;
3645

3746
D)
38-
SELECT C0 FROM UNLIST(text1, text2, text3) AS U(C0);
47+
SELECT C0 FROM UNLIST('text1, text2, text3') AS U(C0);
3948

4049
E)
41-
SELECT U.C0 FROM UNLIST(text1, text2, text3) AS U(C0);
50+
SELECT U.C0 FROM UNLIST('text1, text2, text3') AS U(C0);
4251

4352
F)
4453
SET TERM ^ ;

0 commit comments

Comments
 (0)