pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Albert REINER <areiner@tph.tuwien.ac.at>
To: PostgreSQL-SQL <pgsql-sql@postgreSQL.org>
Subject: IFNULL - problem
Date: Sun, 26 Sep 1999 17:28:37 +0200
Message-ID: <19990926172837.A261@frithjof> (raw)

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@tph.tuwien.ac.at>
---------------------------------------------------------------------------



view thread (4+ messages)  latest in thread

Message-ID: <19990926172837.A261@frithjof>
Permalink:  ../19990926172837.A261@frithjof/
Also on:    postgresql.org/message-id/19990926172837.A261@frithjof

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: areiner@tph.tuwien.ac.at
  Subject: Re: IFNULL - problem
  In-Reply-To: <19990926172837.A261@frithjof>
  References: <19990926172837.A261@frithjof>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox