From: Oliver Elphick <olly@lfix.co.uk>
To: David Olbersen <dave@slickness.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Don't want blank data
Date: Thu, 25 Jan 2001 22:54:44 +0000
Message-ID: <200101252254.f0PMsjF29332@linda.lfix.co.uk> (raw)
In-Reply-To: <dave@slickness.org> <Pine.LNX.4.31.0101251101570.15177-100000@bubbles.electricutopia.net>
David Olbersen wrote:
>Greetings,
> Is there a way to have postgresql always return a value for each row
> requested? To be more clear, if I were using a Perl SQL hybrid I would wri
>te
> something like
>
> SELECT computer_ip or 'unset' FROM computers;
>
> So that if computers.computer_ip is NULL or '' I will get 'unset' back fro
>m
> the database. I hope this makes sense and somebody can point me in a good
> direction
SELECT COALESCE(computer_ip,'unset') AS computer_ip FROM computers;
COALESCE() returns the leftmost non-null value from its parameters.
--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"My little children, let us not love in word, neither
in tongue; but in deed and in truth."
I John 3:18
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: olly@lfix.co.uk, dave@slickness.org
Subject: Re: Don't want blank data
In-Reply-To: <200101252254.f0PMsjF29332@linda.lfix.co.uk>
References: <200101252254.f0PMsjF29332@linda.lfix.co.uk>
* 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