IFNULL - problem

From: "Albert REINER" <areiner(at)tph(dot)tuwien(dot)ac(dot)at>
To: PostgreSQL-SQL <pgsql-sql(at)postgreSQL(dot)org>
Subject: IFNULL - problem
Date: 1999-09-26 15:28:37
Message-ID: 19990926172837.A261@frithjof
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi, I'm using PostgreSQL 6.5.1, and when I try to use IFNULL (listed
in the SQL Functions section of the docs in
/doc.html/user/functions.htm#AEN2121, as:

Table 5-1. SQL Functions
Function Returns Description Example
...
IFNULL(input,non-NULL substitute) non-NULL return second argument if
first is NULL IFNULL(c1, 'N/A')
...

), psql complains about not knowing such a function:

albert=> select ifnull(NULL, 'ASDF');
ERROR: No such function 'ifnull' with the specified attributes
albert=> select ifnull(1, 2);
ERROR: No such function 'ifnull' with the specified attributes

What I really want to do is something like:

albert=> \d mailcalendar
Table = mailcalendar
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| base | datetime | 8 |
| repeat | reltime | 4 |
| offs | reltime | 4 |
| next | datetime | 8 |
| mail | text | var |
+----------------------------------+----------------------------------+-------+
albert=> select ifnull(next, base) as asdf from mailcalendar;
ERROR: No such function 'ifnull' with the specified attributes

What's wrong here? Am I just misusing this feature, or is it really
missing? I know that I can work around it by using case, but this is a
bit less convenient.

albert=> select case when next is null then base else next end as asdf from mailcalendar;
asdf
----------------------------
Sun Sep 26 00:00:00 1971 MET
(1 row)

Albert.

--

---------------------------------------------------------------------------
Post an / Mail to / Skribu al: Albert Reiner <areiner(at)tph(dot)tuwien(dot)ac(dot)at>
---------------------------------------------------------------------------

Browse pgsql-sql by date

  From Date Subject
Next Message Mukund Chandak 1999-09-26 15:29:31 Pgsql tutorial
Previous Message omid omoomi 1999-09-26 04:02:09 RE: [SQL] comparing 2 tables. . .