comparison doc/manual.tex @ 1602:e44be6ece475

COALESCE
author Adam Chlipala <adam@chlipala.net>
date Sat, 19 Nov 2011 10:43:57 -0500
parents d9de8b3f8167
children b1af16cdc659
comparison
equal deleted inserted replaced
1601:78e0d56b594e 1602:e44be6ece475
1707 $$\begin{array}{l} 1707 $$\begin{array}{l}
1708 \mt{val} \; \mt{sql\_is\_null} : \mt{tables} ::: \{\{\mt{Type}\}\} \to \mt{agg} ::: \{\{\mt{Type}\}\} \to \mt{exps} ::: \{\mt{Type}\} \to \mt{t} ::: \mt{Type} \\ 1708 \mt{val} \; \mt{sql\_is\_null} : \mt{tables} ::: \{\{\mt{Type}\}\} \to \mt{agg} ::: \{\{\mt{Type}\}\} \to \mt{exps} ::: \{\mt{Type}\} \to \mt{t} ::: \mt{Type} \\
1709 \hspace{.1in} \to \mt{sql\_exp} \; \mt{tables} \; \mt{agg} \; \mt{exps} \; (\mt{option} \; \mt{t}) \to \mt{sql\_exp} \; \mt{tables} \; \mt{agg} \; \mt{exps} \; \mt{bool} 1709 \hspace{.1in} \to \mt{sql\_exp} \; \mt{tables} \; \mt{agg} \; \mt{exps} \; (\mt{option} \; \mt{t}) \to \mt{sql\_exp} \; \mt{tables} \; \mt{agg} \; \mt{exps} \; \mt{bool}
1710 \end{array}$$ 1710 \end{array}$$
1711 1711
1712 As another way of dealing with null values, there is also a restricted form of the standard \cd{COALESCE} function.
1713 $$\begin{array}{l}
1714 \mt{val} \; \mt{sql\_coalesce} : \mt{tables} ::: \{\{\mt{Type}\}\} \to \mt{agg} ::: \{\{\mt{Type}\}\} \to \mt{exps} ::: \{\mt{Type}\} \\
1715 \hspace{.1in} \to \mt{t} ::: \mt{Type} \\
1716 \hspace{.1in} \to \mt{sql\_exp} \; \mt{tables} \; \mt{agg} \; \mt{exps} \; (\mt{option} \; \mt{t}) \\
1717 \hspace{.1in} \to \mt{sql\_exp} \; \mt{tables} \; \mt{agg} \; \mt{exps} \; \mt{t} \\
1718 \hspace{.1in} \to \mt{sql\_exp} \; \mt{tables} \; \mt{agg} \; \mt{exps} \; \mt{t}
1719 \end{array}$$
1720
1712 We have generic nullary, unary, and binary operators. 1721 We have generic nullary, unary, and binary operators.
1713 $$\begin{array}{l} 1722 $$\begin{array}{l}
1714 \mt{con} \; \mt{sql\_nfunc} :: \mt{Type} \to \mt{Type} \\ 1723 \mt{con} \; \mt{sql\_nfunc} :: \mt{Type} \to \mt{Type} \\
1715 \mt{val} \; \mt{sql\_current\_timestamp} : \mt{sql\_nfunc} \; \mt{time} \\ 1724 \mt{val} \; \mt{sql\_current\_timestamp} : \mt{sql\_nfunc} \; \mt{time} \\
1716 \mt{val} \; \mt{sql\_nfunc} : \mt{tables} ::: \{\{\mt{Type}\}\} \to \mt{agg} ::: \{\{\mt{Type}\}\} \to \mt{exps} ::: \{\mt{Type}\} \to \mt{t} ::: \mt{Type} \\ 1725 \mt{val} \; \mt{sql\_nfunc} : \mt{tables} ::: \{\{\mt{Type}\}\} \to \mt{agg} ::: \{\{\mt{Type}\}\} \to \mt{exps} ::: \{\mt{Type}\} \to \mt{t} ::: \mt{Type} \\
2138 &&& \{e\} & \textrm{computed expressions, probably using $\mt{sql\_exp}$ directly} \\ 2147 &&& \{e\} & \textrm{computed expressions, probably using $\mt{sql\_exp}$ directly} \\
2139 &&& \mt{TRUE} \mid \mt{FALSE} & \textrm{boolean constants} \\ 2148 &&& \mt{TRUE} \mid \mt{FALSE} & \textrm{boolean constants} \\
2140 &&& \ell & \textrm{primitive type literals} \\ 2149 &&& \ell & \textrm{primitive type literals} \\
2141 &&& \mt{NULL} & \textrm{null value (injection of $\mt{None}$)} \\ 2150 &&& \mt{NULL} & \textrm{null value (injection of $\mt{None}$)} \\
2142 &&& E \; \mt{IS} \; \mt{NULL} & \textrm{nullness test} \\ 2151 &&& E \; \mt{IS} \; \mt{NULL} & \textrm{nullness test} \\
2152 &&& \mt{COALESCE}(E, E) & \textrm{take first non-null value} \\
2143 &&& n & \textrm{nullary operators} \\ 2153 &&& n & \textrm{nullary operators} \\
2144 &&& u \; E & \textrm{unary operators} \\ 2154 &&& u \; E & \textrm{unary operators} \\
2145 &&& E \; b \; E & \textrm{binary operators} \\ 2155 &&& E \; b \; E & \textrm{binary operators} \\
2146 &&& \mt{COUNT}(\ast) & \textrm{count number of rows} \\ 2156 &&& \mt{COUNT}(\ast) & \textrm{count number of rows} \\
2147 &&& a(E) & \textrm{other aggregate function} \\ 2157 &&& a(E) & \textrm{other aggregate function} \\