pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jason Earl <jearl@box100.com>
To: matthew@venux.net
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] Problems with money fields.
Date: Tue, 18 May 1999 21:21:40 -0600
Message-ID: <199905190321.VAA28844@earlj.nesusa.com> (raw)
In-Reply-To: <4.1.19990518203016.00ae1d00@mail.venux.net>
References: <4.1.19990518203016.00ae1d00@mail.venux.net>

Apparently a NULL money value is not equal to zero.  That is probably
a good thing.

The select you want for selecting all of the null values is:

SELECT * FROM test WHERE total IS NULL;


   Hello,

   I was wondering if someone could shed some light on money fileds for me.  I
   am having a problem in that a money field plus a null money field equals
   null.  Try this:

   create table test(total money);
   insert into test values('');
   insert into test valuse(NULL);

   select * from test;
   total
   -----
   $0.00

   (2 rows)

   select '1'::money + total from test;
   ?column?
   --------
   $1.00   

   (2 rows)

   Why is the second column blank?  This is really throwing my calculations
   because there are times when $0.00 is different from no value at all.
   Also, how can I get a query of all rows where the money value is NULL?
   This fails:

   select * from test where total = NULL;
   ERROR:  parser: parse error at or near "null"

   and this gives me the rows with $0.00:

   select * from test where total = '';  
   total
   -----
   $0.00
   (1 row)

   If I can't query for a money field with a NULL value, why can I insert one?

   Thank you,
   Matthew Hagerty





view thread (3+ messages)  latest in thread

Message-ID: <199905190321.VAA28844@earlj.nesusa.com>
Permalink:  ../199905190321.VAA28844@earlj.nesusa.com/
Also on:    postgresql.org/message-id/199905190321.VAA28844@earlj.nesusa.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: jearl@box100.com, matthew@venux.net
  Subject: Re: [INTERFACES] Problems with money fields.
  In-Reply-To: <199905190321.VAA28844@earlj.nesusa.com>

* 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