pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedDon't want blank data
3+ messages / 3 participants
[nested] [flat]
* Don't want blank data
@ 2001-01-25 19:05 David Olbersen <dave@slickness.org>
0 siblings, 2 replies; 3+ messages in thread
From: David Olbersen @ 2001-01-25 19:05 UTC (permalink / raw)
To: pgsql-sql
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 write
something like
SELECT computer_ip or 'unset' FROM computers;
So that if computers.computer_ip is NULL or '' I will get 'unset' back from
the database. I hope this makes sense and somebody can point me in a good
direction
-- Dave
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Don't want blank data
@ 2001-01-25 20:43 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: David Olbersen <dave@slickness.org>
1 sibling, 0 replies; 3+ messages in thread
From: Stephan Szabo @ 2001-01-25 20:43 UTC (permalink / raw)
To: David Olbersen <dave@slickness.org>; +Cc: pgsql-sql
On Thu, 25 Jan 2001, 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 write
> something like
>
> SELECT computer_ip or 'unset' FROM computers;
>
> So that if computers.computer_ip is NULL or '' I will get 'unset' back from
> the database. I hope this makes sense and somebody can point me in a good
> direction
Perhaps:
select case when computer_ip is null or computer_ip='' then 'unset'::text
else computer_ip end from computers;
(the ::text should probably be whatever type computer_ip is)...
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Don't want blank data
@ 2001-01-25 22:54 Oliver Elphick <olly@lfix.co.uk>
parent: David Olbersen <dave@slickness.org>
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Elphick @ 2001-01-25 22:54 UTC (permalink / raw)
To: David Olbersen <dave@slickness.org>; +Cc: pgsql-sql
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-01-25 22:54 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-25 19:05 Don't want blank data David Olbersen <dave@slickness.org>
2001-01-25 20:43 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2001-01-25 22:54 ` Oliver Elphick <olly@lfix.co.uk>
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