Re: NULL OR ZERO

From: Andrei Kovalevski <andyk(at)commandprompt(dot)com>
To: Omar Bettin <o(dot)bettin(at)tiscali(dot)it>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: NULL OR ZERO
Date: 2008-02-04 11:16:23
Message-ID: 47A6F407.5080708@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

Omar Bettin wrote:
> Probably I am on the wrong place but for me NULL on numbers means 0 or
> ZERO.
> I know about standards...
>

You can easily convert NULLs to 0 in your queries - read about COALESCE
function
http://www.postgresql.org/docs/8.0/interactive/functions-conditional.html.
Compare these SELECTs:

CREATE TABLE test (num INTEGER);
INSERT INTO test VALUES (1), (2), (null), (3), (null), (4), (0);

SELECT num FROM test;

SELECT COALESCE(num, 0) FROM test;

> but I think that integralism is somewhat wrong.
>
> Omar
> a programmer...
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match

--
Andrei Kovalevski
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, ODBCng - http://www.commandprompt.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kenneth Marshall 2008-02-04 13:35:07 Re: [HACKERS] Reverse key index
Previous Message Simon Riggs 2008-02-04 09:39:59 Re: configurability of OOM killer