Re: Decimal ??
От | Jason Earl |
---|---|
Тема | Re: Decimal ?? |
Дата | |
Msg-id | 20000524044310.7379.qmail@web111.yahoomail.com обсуждение исходный текст |
Ответ на | Decimal ?? (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/
В списке pgsql-sql по дате отправления: