NVL vs COALESCE
NVL vs COALESCE
От:
Marcus Engene <mengpg@engene.se>
Дата:
When we're having an alias discussion, I'd really like to see NVL in postgres. Not because of porting from oracle as much as just spelling that without the reference manual is completely impossible. Best regards, Marcus
Re: NVL vs COALESCE
От:
Michael Glaesemann <grzm@myrealbox.com>
Дата:
On Nov 24, 2005, at 21:21 , Marcus Engene wrote: > When we're having an alias discussion, I'd really like to see NVL > in postgres. Not because of porting from oracle as much as just > spelling that without the reference manual is completely impossible. NVL: what a very unfortunate spelling. (NULL VaLue? NULL Valued Logic? Named Very Loosely? Someone help me here :) ) AFAICT, COALESCE is SQL standard, while NVL isn't. I think an index entry might be a good idea. Michael Glaesemann grzm myrealbox com
Re: NVL vs COALESCE
От:
Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Дата:
If we're going to do that we should add IFNULL() from MySQL as well... Chris Michael Glaesemann wrote: > > On Nov 24, 2005, at 21:21 , Marcus Engene wrote: > >> When we're having an alias discussion, I'd really like to see NVL in >> postgres. Not because of porting from oracle as much as just spelling >> that without the reference manual is completely impossible. > > > NVL: what a very unfortunate spelling. (NULL VaLue? NULL Valued Logic? > Named Very Loosely? Someone help me here :) ) AFAICT, COALESCE is SQL > standard, while NVL isn't. I think an index entry might be a good idea. > > Michael Glaesemann > grzm myrealbox com > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings
Re: NVL vs COALESCE
От:
"Pavel Stehule" <pavel.stehule@hotmail.com>
Дата:
>When we're having an alias discussion, I'd really like to see NVL in >postgres. Not because of porting from oracle as much as just spelling that >without the reference manual is completely impossible. > >Best regards, >Marcus > > You can found NVL in orafunc on pgfoundry. Regards Pavel Stehule _________________________________________________________________ Emotikony a pozadi programu MSN Messenger ozivi vasi konverzaci. http://messenger.msn.cz/
Re: NVL vs COALESCE
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Michael Glaesemann wrote:
>
> On Nov 24, 2005, at 21:21 , Marcus Engene wrote:
>
> > When we're having an alias discussion, I'd really like to see NVL
> > in postgres. Not because of porting from oracle as much as just
> > spelling that without the reference manual is completely impossible.
>
> NVL: what a very unfortunate spelling. (NULL VaLue? NULL Valued
> Logic? Named Very Loosely? Someone help me here :) ) AFAICT, COALESCE
> is SQL standard, while NVL isn't. I think an index entry might be a
> good idea.
Agreed, documentation patch applied to HEAD and 8.1.X.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.295
diff -c -c -r1.295 func.sgml
*** doc/src/sgml/func.sgml 19 Nov 2005 19:44:54 -0000 1.295
--- doc/src/sgml/func.sgml 28 Nov 2005 23:17:42 -0000
***************
*** 7227,7232 ****
--- 7227,7240 ----
COALESCE
+
+ NVL
+
+
+
+ IFNULL
+
+
COALESCE(value , ...)
***************
*** 7234,7242 ****
The COALESCE function returns the first of its
arguments that is not null. Null is returned only if all arguments
! are null. This is often useful to substitute a
! default value for null values when data is retrieved for display,
! for example:
SELECT COALESCE(description, short_description, '(none)') ...
--- 7242,7249 ----
The COALESCE function returns the first of its
arguments that is not null. Null is returned only if all arguments
! are null. It is often used to substitute a default value for
! null values when data is retrieved for display, for example:
SELECT COALESCE(description, short_description, '(none)') ...
***************
*** 7246,7252 ****
Like a CASE expression, COALESCE will
not evaluate arguments that are not needed to determine the result;
that is, arguments to the right of the first non-null argument are
! not evaluated.
--- 7253,7261 ----
Like a CASE expression, COALESCE will
not evaluate arguments that are not needed to determine the result;
that is, arguments to the right of the first non-null argument are
! not evaluated. This SQL-standard function provides capabilities similar
! to NVL</> and IFNULL</>, which are used in some other
! database systems.
***************
*** 7262,7277 ****
! The NULLIF function returns a null value if and only
! if value1 and
! value2 are equal. Otherwise it returns
! value1. This can be used to perform the
! inverse operation of the COALESCE example
! given above:
SELECT NULLIF(value, '(none)') ...
--- 7271,7289 ----
! The NULLIF function returns a null value if
! value1 and value2
! are equal; otherwise it returns value1.
! This can be used to perform the inverse operation of the
! COALESCE example given above:
SELECT NULLIF(value, '(none)') ...
+
+ If value1 is (none)</>, return a null,
+ otherwise return value1.
+