Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Brent Wood
Thanks Adrian, That's perfect!! Cheers, Brent Brent Wood DBA/GIS consultant NIWA, Wellington New Zealand >>> Adrian Klaver <[EMAIL PROTECTED]> 11/08/08 1:49 PM >>> On Friday 07 November 2008 4:05:08 pm Brent Wood wrote: > Thanks guys, > > I'm aware of those options, what I was wondering was

Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Adrian Klaver
On Friday 07 November 2008 4:05:08 pm Brent Wood wrote: > Thanks guys, > > I'm aware of those options, what I was wondering was if there is a more > generic way, for example the Empress RDBMS allows 'set MSNULLVALUE "NA"', > and all NULLs will from then on be output as NA. > > The COPY option is cl

Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Ivan Sergio Borgonovo
On Sat, 08 Nov 2008 13:05:08 +1300 "Brent Wood" <[EMAIL PROTECTED]> wrote: > Thanks guys, > > I'm aware of those options, what I was wondering was if there is a > more generic way, for example the Empress RDBMS allows 'set > MSNULLVALUE "NA"', and all NULLs will from then on be output as NA. > >

Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Brent Wood
Thanks guys, I'm aware of those options, what I was wondering was if there is a more generic way, for example the Empress RDBMS allows 'set MSNULLVALUE "NA"', and all NULLs will from then on be output as NA. The COPY option is closest to a generic setting, but doesn't work with a select query

Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Mike Toews
Mike Toews wrote: Keep in mind that you can't mix data types, like 'NaN'::text and 32.3::float in the result. oh yeah, regarding mixing data types (in regards to the first post)... A good exception is that you can use 'NaN' for floating point data types, so: SELECT COALESCE(myval, 'NaN')

Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Mike Toews
Said Ramirez wrote: I think you are more after something like SELECT CASE WHEN foo IS NULL THEN 'NA' END FROM bar. -Said An even simpler way to do this is using the COALESCE function: http://www.postgresql.org/docs/current/interactive/functions-conditional.html SELECT COALESCE(foo, 'NA') AS

Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Ivan Sergio Borgonovo
On Fri, 07 Nov 2008 15:20:24 -0500 Said Ramirez <[EMAIL PROTECTED]> wrote: > I think you are more after something like > > SELECT CASE WHEN foo IS NULL THEN 'NA' END FROM bar. missing an else at least and... wtw_drupal=# create table test.test(c1 int); CREATE TABLE wtw_drupal=# insert into test

Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Said Ramirez
I think you are more after something like SELECT CASE WHEN foo IS NULL THEN 'NA' END FROM bar. -Said Ivan Sergio Borgonovo wrote: On Thu, 6 Nov 2008 17:44:42 -0800 (PST) [EMAIL PROTECTED] wrote: > > Hi, > > I can specify the text used to represent a null value in output > from copy, but

Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Ivan Sergio Borgonovo
On Thu, 6 Nov 2008 17:44:42 -0800 (PST) [EMAIL PROTECTED] wrote: > > Hi, > > I can specify the text used to represent a null value in output > from copy, but I'd like to do something similar is select output, > eg: all NULL values are represented by NA or NaN. > > I can't find anything in the d

[GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread pcreso
Hi, I can specify the text used to represent a null value in output from copy, but I'd like to do something similar is select output, eg: all NULL values are represented by NA or NaN. I can't find anything in the docs about this. This could be managed using case statements around all the colu