Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ee4aa30

Browse files
committed
Improve documentation for COALESCE and NULLIF. Add references for NVL
and IFNULL. Backpatch to 8.1.X.
1 parent 2005450 commit ee4aa30

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

doc/src/sgml/func.sgml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.295 2005/11/19 19:44:54 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.296 2005/11/28 23:18:48 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -7227,16 +7227,23 @@ SELECT ... WHERE CASE WHEN x &lt;&gt; 0 THEN y/x &gt; 1.5 ELSE false END;
72277227
<primary>COALESCE</primary>
72287228
</indexterm>
72297229

7230+
<indexterm>
7231+
<primary>NVL</primary>
7232+
</indexterm>
7233+
7234+
<indexterm>
7235+
<primary>IFNULL</primary>
7236+
</indexterm>
7237+
72307238
<synopsis>
72317239
<function>COALESCE</function>(<replaceable>value</replaceable> <optional>, ...</optional>)
72327240
</synopsis>
72337241

72347242
<para>
72357243
The <function>COALESCE</function> function returns the first of its
72367244
arguments that is not null. Null is returned only if all arguments
7237-
are null. This is often useful to substitute a
7238-
default value for null values when data is retrieved for display,
7239-
for example:
7245+
are null. It is often used to substitute a default value for
7246+
null values when data is retrieved for display, for example:
72407247
<programlisting>
72417248
SELECT COALESCE(description, short_description, '(none)') ...
72427249
</programlisting>
@@ -7246,7 +7253,9 @@ SELECT COALESCE(description, short_description, '(none)') ...
72467253
Like a <token>CASE</token> expression, <function>COALESCE</function> will
72477254
not evaluate arguments that are not needed to determine the result;
72487255
that is, arguments to the right of the first non-null argument are
7249-
not evaluated.
7256+
not evaluated. This SQL-standard function provides capabilities similar
7257+
to <function>NVL</> and <function>IFNULL</>, which are used in some other
7258+
database systems.
72507259
</para>
72517260
</sect2>
72527261

@@ -7262,16 +7271,19 @@ SELECT COALESCE(description, short_description, '(none)') ...
72627271
</synopsis>
72637272

72647273
<para>
7265-
The <function>NULLIF</function> function returns a null value if and only
7266-
if <replaceable>value1</replaceable> and
7267-
<replaceable>value2</replaceable> are equal. Otherwise it returns
7268-
<replaceable>value1</replaceable>. This can be used to perform the
7269-
inverse operation of the <function>COALESCE</function> example
7270-
given above:
7274+
The <function>NULLIF</function> function returns a null value if
7275+
<replaceable>value1</replaceable> and <replaceable>value2</replaceable>
7276+
are equal; otherwise it returns <replaceable>value1</replaceable>.
7277+
This can be used to perform the inverse operation of the
7278+
<function>COALESCE</function> example given above:
72717279
<programlisting>
72727280
SELECT NULLIF(value, '(none)') ...
72737281
</programlisting>
72747282
</para>
7283+
<para>
7284+
If <replaceable>value1</replaceable> is <literal>(none)</>, return a null,
7285+
otherwise return <replaceable>value1</replaceable>.
7286+
</para>
72757287

72767288
</sect2>
72777289

0 commit comments

Comments
 (0)