pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Anton de Wet <adw@obsidian.co.za>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Letting a function work on NULL
Date: Mon, 21 Jun 1999 13:57:31 +0300
Message-ID: <l03130302b393b9495dc4@[147.233.159.109]> (raw)
In-Reply-To: <Pine.LNX.4.10.9906202049050.21065-100000@ra.obsidian.co.za>

At 21:53 +0300 on 20/06/1999, Anton de Wet wrote:


> But all gives:
>
> select ym(NULL);
> ERROR:  typeidTypeRelid: Invalid type - oid = 0
>
> Is there any way to specify an exception on the input type?

There are two different issues here. First, passing the "literal" NULL to
functions always results in this. In SQL92, NULL is not even considered a
literal. Try this, for example:

testing=> select abstime( NULL ) from test2;
ERROR:  typeidTypeRelid: Invalid type - oid = 0

(abstime() is a builting function converting to abstime);

In order to test the functionality of a function in nulls, you should
create a table, some of whose values are null:

testing=> select f, abstime( f ) from test2;
           f|abstime
------------+----------------------------
3.1415926535|Sat Jan 01 02:00:03 2000 IST
            |
     1.11111|Sat Jan 01 02:00:01 2000 IST
(3 rows)

That's about your testing procedure. About your problem in itself: you
should either use a pl/pgsql procedure or make use of COALESCE.

One last note: EXCEPT is a query operator that excludes certain tuples from
a query. It's not an "else". When you write "SELECT something1 EXCEPT
SELECT something2", it means "select all the 'something1' objects which are
not 'something2'

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (3+ messages)  latest in thread

Message-ID: <l03130302b393b9495dc4@[147.233.159.109]>
Permalink:  ../l03130302b393b9495dc4@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130302b393b9495dc4@[147.233.159.109]

 · 

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: herouth@oumail.openu.ac.il, adw@obsidian.co.za
  Subject: Re: [SQL] Letting a function work on NULL
  In-Reply-To: <l03130302b393b9495dc4@[147.233.159.109]>
  References: <Pine.LNX.4.10.9906202049050.21065-100000@ra.obsidian.co.za> <l03130302b393b9495dc4@[147.233.159.109]>

* 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