pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feeddecimal
6+ messages / 5 participants
[nested] [flat]
* decimal
@ 1999-09-22 12:09 Aleš Vojáček <alesv@fbl.cz>
1999-09-22 13:23 ` Re: [SQL] decimal Jeff MacDonald <jeff@hub.org>
1999-09-22 15:06 ` Re: [SQL] decimal Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 6+ messages in thread
From: Aleš Vojáček @ 1999-09-22 12:09 UTC (permalink / raw)
To: pgsql-sql@hub.org
Hi all,
I'm new in postress world,
I have one question exists any datatype like decimal (12,6) (123456789012.123456) in postgress?
sorry for my english
Ales
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [SQL] decimal
1999-09-22 12:09 decimal Aleš Vojáček <alesv@fbl.cz>
@ 1999-09-22 13:23 ` Jeff MacDonald <jeff@hub.org>
1 sibling, 0 replies; 6+ messages in thread
From: Jeff MacDonald @ 1999-09-22 13:23 UTC (permalink / raw)
To: Ale¹ Vojáèek <alesv@fbl.cz>; +Cc: pgsql-sql
greetings,
you need the numeric type
ie
create table example(
thisvaluse numeric(12,6)
);
insert into table example values(012345678912.012345);
On Wed, 22 Sep 1999, Ale¹ Vojáèek wrote:
> Hi all,
> I'm new in postress world,
> I have one question exists any datatype like decimal (12,6) (123456789012.123456) in postgress?
> sorry for my english
> Ales
>
======================================================
Jeff MacDonald
jeff@hub.org webpage: http://hub.org/~jeff
jeff@pgsql.com irc: bignose on EFnet
======================================================
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [SQL] decimal
1999-09-22 12:09 decimal Aleš Vojáček <alesv@fbl.cz>
@ 1999-09-22 15:06 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 6+ messages in thread
From: Tom Lane @ 1999-09-22 15:06 UTC (permalink / raw)
To: Aleš Vojáček <alesv@fbl.cz>; +Cc: pgsql-sql@hub.org
"=?iso-8859-2?B?QWxluSBWb2rh6GVr?=" <alesv@fbl.cz> writes:
> <META content=3Dtext/html;charset=3Diso-8859-2 =
> http-equiv=3DContent-Type>
> <META content=3D'"MSHTML 4.72.3110.7"' name=3DGENERATOR>
> </HEAD>
> <BODY bgColor=3D#ffffff>
> <DIV><FONT color=3D#000000 size=3D2>Hi all,</FONT></DIV>
> <DIV><FONT color=3D#000000 size=3D2>I'm new in postress world, =
> </FONT></DIV>
> <DIV><FONT color=3D#000000 size=3D2>I have one question exists any =
> datatype like=20
> decimal (12,6) (123456789012.123456) in postgress?</FONT></DIV>
> <DIV><FONT color=3D#000000 size=3D2>sorry for my english</FONT></DIV>
> <DIV><FONT color=3D#000000 size=3D2>Ales</FONT></DIV></BODY></HTML>
Please don't use HTML in email...
Yes, there's a full decimal/numeric implementation in Postgres 6.5
and later.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Decimal ??
@ 2000-05-24 02:55 Tubagus Nizomi <nizomi@dnet.net.id>
2000-05-24 04:44 ` Re: Decimal ?? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Tubagus Nizomi @ 2000-05-24 02:55 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Decimal ??
2000-05-24 02:55 Decimal ?? Tubagus Nizomi <nizomi@dnet.net.id>
@ 2000-05-24 04:44 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 6+ messages in thread
From: Tom Lane @ 2000-05-24 04:44 UTC (permalink / raw)
To: Tubagus Nizomi <nizomi@dnet.net.id>; +Cc: pgsql-sql
Tubagus Nizomi <nizomi@dnet.net.id> writes:
> I have table :
> create table test (name text, price numeric(6,2));
> but when i insert into test values ('John',3/4);
> why this value 0.00 but i want to 0.75 ??? help me please.
Offhand I'd bet that "3/4" is being interpreted as an integer
division expression. Try "3.0/4.0" or some such if you want
a fractional result...
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Decimal ??
@ 2000-05-24 04:43 Jason Earl <jdearl@yahoo.com>
0 siblings, 0 replies; 6+ messages in thread
From: Jason Earl @ 2000-05-24 04:43 UTC (permalink / raw)
To: Tubagus Nizomi <nizomi@dnet.net.id>; pgsql-sql
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/
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2000-05-24 04:44 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-09-22 12:09 decimal Aleš Vojáček <alesv@fbl.cz>
1999-09-22 13:23 ` Jeff MacDonald <jeff@hub.org>
1999-09-22 15:06 ` Tom Lane <tgl@sss.pgh.pa.us>
2000-05-24 02:55 Decimal ?? Tubagus Nizomi <nizomi@dnet.net.id>
2000-05-24 04:44 ` Re: Decimal ?? Tom Lane <tgl@sss.pgh.pa.us>
2000-05-24 04:43 Re: Decimal ?? Jason Earl <jdearl@yahoo.com>
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