mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-02-02 08:00:39 +01:00
update readme's with method used for determing result data type
This commit is contained in:
parent
1ee8ebf133
commit
56892f3fb0
@ -1,3 +1,5 @@
|
|||||||
|
SQL Language Extension: CASE
|
||||||
|
|
||||||
Function:
|
Function:
|
||||||
Allow the result of a column to be determined by a the results of a
|
Allow the result of a column to be determined by a the results of a
|
||||||
case expression.
|
case expression.
|
||||||
@ -6,8 +8,6 @@ Author:
|
|||||||
Arno Brinkman <firebird@abvisie.nl>
|
Arno Brinkman <firebird@abvisie.nl>
|
||||||
|
|
||||||
Format:
|
Format:
|
||||||
|
|
||||||
|
|
||||||
<case expression> ::=
|
<case expression> ::=
|
||||||
<case abbreviation>
|
<case abbreviation>
|
||||||
| <case specification>
|
| <case specification>
|
||||||
@ -46,9 +46,8 @@ Format:
|
|||||||
|
|
||||||
<result expression> ::= <value expression>
|
<result expression> ::= <value expression>
|
||||||
|
|
||||||
|
Notes:
|
||||||
Syntax Rules:
|
See also README.data_type_results_of_aggregations.txt
|
||||||
|
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
SQL Language Extension: COALESCE
|
||||||
|
|
||||||
Function:
|
Function:
|
||||||
Allow a column value to be calculated by a number of expressions,
|
Allow a column value to be calculated by a number of expressions,
|
||||||
the first expression returning a non NULL value is returned as the
|
the first expression returning a non NULL value is returned as the
|
||||||
@ -19,6 +21,8 @@ Syntax Rules:
|
|||||||
<case specification>:
|
<case specification>:
|
||||||
CASE WHEN V1 IS NOT NULL THEN V1 ELSE COALESCE (V2,...,Vn) END
|
CASE WHEN V1 IS NOT NULL THEN V1 ELSE COALESCE (V2,...,Vn) END
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
See also README.data_type_results_of_aggregations.txt
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
A)
|
A)
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
Function:
|
||||||
|
Specify the result data type of the result of an aggregation over values of
|
||||||
|
compatible data types, such as case expressions and columns at the same
|
||||||
|
position in a union query expression.
|
||||||
|
|
||||||
|
Author:
|
||||||
|
Arno Brinkman <firebird@abvisie.nl>
|
||||||
|
|
||||||
|
Syntax Rules:
|
||||||
|
|
||||||
|
1) Let DTS be the set of data types over which we must determine the final
|
||||||
|
result data type.
|
||||||
|
|
||||||
|
2) All of the data types in DTS shall be comparable.
|
||||||
|
|
||||||
|
3) Case:
|
||||||
|
|
||||||
|
a) If any of the data types in DTS is character string, then:
|
||||||
|
|
||||||
|
1) If any of the data types in DTS is variable-length character string,
|
||||||
|
then the result data type is variable-length character string with
|
||||||
|
maximum length in characters equal to the maximum of the lengths in
|
||||||
|
characters and maximum lengths in characters of the data types in DTS.
|
||||||
|
|
||||||
|
2) Otherwise, the result data type is fixed-length character string with
|
||||||
|
length in characters equal to the maximum of the lengths in
|
||||||
|
characters of the data types in DTS.
|
||||||
|
|
||||||
|
3) The characterset/collation is used from the first character string
|
||||||
|
data type in DTS.
|
||||||
|
|
||||||
|
b) If all of the data types in DTS are exact numeric, then the result data
|
||||||
|
type is exact numeric with scale equal to the maximum of the scales of
|
||||||
|
the data types in DTS and the maximum precision of all data types in DTS.
|
||||||
|
|
||||||
|
c) If any data type in DTS is approximate numeric, then each data type in DTS
|
||||||
|
shall be numeric else an error is thrown.
|
||||||
|
|
||||||
|
d) If some data type in DTS is a datetime data type, then every data type in
|
||||||
|
DTS shall be a datetime data type having the same datetime type.
|
||||||
|
|
||||||
|
e) If any data type in DTS is BLOB, then each data type in DTS shall be
|
||||||
|
BLOB and all with the same sub-type.
|
||||||
|
|
@ -38,9 +38,8 @@ Notes:
|
|||||||
The optimizer can handle a derived table very efficiently, but if the
|
The optimizer can handle a derived table very efficiently, but if the
|
||||||
derived table contains a sub-select then no join order can be made (if the
|
derived table contains a sub-select then no join order can be made (if the
|
||||||
derived table is included in an inner join).
|
derived table is included in an inner join).
|
||||||
|
|
||||||
|
|
||||||
Example(s):
|
Examples:
|
||||||
|
|
||||||
a) Simple derived table:
|
a) Simple derived table:
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
SQL Language Extension: NULLIF
|
||||||
|
|
||||||
Function:
|
Function:
|
||||||
Return a NULL value for a sub-expression if it has a specific value
|
Return a NULL value for a sub-expression if it has a specific value
|
||||||
otherwise return the value of the sub-expression
|
otherwise return the value of the sub-expression
|
||||||
@ -10,13 +12,15 @@ Format:
|
|||||||
<case abbreviation> ::=
|
<case abbreviation> ::=
|
||||||
NULLIF <left paren> <value expression> <comma> <value expression> <right paren>
|
NULLIF <left paren> <value expression> <comma> <value expression> <right paren>
|
||||||
|
|
||||||
|
|
||||||
Syntax Rules:
|
Syntax Rules:
|
||||||
1) NULLIF (V1, V2) is equivalent to the following <case specification>:
|
1) NULLIF (V1, V2) is equivalent to the following <case specification>:
|
||||||
CASE WHEN V1 = V2 THEN NULL ELSE V1 END
|
CASE WHEN V1 = V2 THEN NULL ELSE V1 END
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
See also README.data_type_results_of_aggregations.txt
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
A)
|
A)
|
||||||
UPDATE PRODUCTS
|
UPDATE PRODUCTS
|
||||||
SET STOCK = NULLIF(STOCK,0)
|
SET STOCK = NULLIF(STOCK,0)
|
||||||
|
Loading…
Reference in New Issue
Block a user