pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Jason Earl <jdearl@yahoo.com>
To: Tubagus Nizomi <nizomi@dnet.net.id>
To: pgsql-sql@postgresql.org
Subject: Re: Decimal ??
Date: Tue, 23 May 2000 21:43:10 -0700 (PDT)
Message-ID: <20000524044310.7379.qmail@web111.yahoomail.com> (raw)
In PostgreSQL 7.0 (and I would bet 6.5) if you cast
either the numerator or the denominator as a numeric
then it does what you would expect.
For example:
insert into test (name, price) values ('Jason',
3::numeric/4);
OR
insert into test (name, price) values ('Earl',
3/4::numeric);
Will do what you want. Unfortunately:
insert into test (name, price) values ('Foobar',
(3/4)::numeric);
does _not_ do what you would expect. This (I imagine)
is because PostgreSQL sees the two values, assumes
they are integers and does integer division. Without
knowing exactly what you are trying to do (and what
language you are trying to do it in) it is hard to
guess if this is helpful, so write back if you need
more help.
Hopefully this is helpful.
Jason
--- Tubagus Nizomi <nizomi@dnet.net.id> wrote:
> I have table :
> create table test (name text, price numeric(6,2));
> CREATE
> insert into test values ('John',0.75);
> INSERT
>
> select * from test;
> name | price
> ---------
> John | 0.75
>
> but when i insert into test values ('John',3/4);
> INSERT
>
> select * from test;
> name | price
> ---------
> John | 0.00 ---> ???
>
> why this value 0.00 but i want to 0.75 ??? help me
> please.
>
> i am using mandrake 7 and postgres 6.5.3
>
> Thanks
> Nizomi
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
view thread (6+ messages) latest in thread
Message-ID: <20000524044310.7379.qmail@web111.yahoomail.com> Permalink: ../20000524044310.7379.qmail@web111.yahoomail.com/ Also on: postgresql.org/message-id/20000524044310.7379.qmail@web111.yahoomail.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 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: jdearl@yahoo.com, nizomi@dnet.net.id Subject: Re: Decimal ?? In-Reply-To: <20000524044310.7379.qmail@web111.yahoomail.com> References: <20000524044310.7379.qmail@web111.yahoomail.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