Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data type money in postgres

Status
Not open for further replies.

JJJ777

Programmer
Jun 5, 2002
33
0
0
MY
hi all...

I have problem when using "money" as data type when
performing calculation.

this data type suddenly produce -ve value.

for example?

1) insert 1000000000 ..it becomes 12,157,521.92
2) insert 2000000000 ...it becomes -18,634,629.12

why after 10 character it display other value?
Need help ..i'm confuse ...
tq in advance
 
what version are you using, it is quite strange

show some code, how do get this, because here's what I get

test=# create table money( price money not null);
CREATE TABLE
test=# insert into money values (1000000000);
ERROR: column "price" is of type money but expression is of type integer
HINT: You will need to rewrite or cast the expression.
test=# select version();
version
-------------------------------------------------------------------------------------------
PostgreSQL 8.0.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.5 (Debian 1:3.3.5-5)
(1 row)
 
1st of all tq....

my version :

select version();
version
------------------------------------------------------------------------------------------------
PostgreSQL 7.3.9 on i386-portbld-freebsd5.4, compiled by GCC cc (GCC) 3.4.2 [FreeBSD] 20040728

at first i thought my code was not proper...but then i directly insert it and the result was same.i notice that
the money type got limitation which are :

Table 8-3. Monetary Types from postgresql documentation

Name Storage Size Description Range
money 4 bytes currency amount -21474836.48 to +21474836.47

mmm but i didnt try it on version 8 yet.
 
continue ...

machine=# INSERT INTO money VALUES ('1000000000');
INSERT 107451 1
machine=# INSERT INTO money VALUES ('2000000000');
INSERT 107452 1
machine=# SELECT * from money;
price
-----------------
$12,157,521.92
-$18,634,629.12
(2 rows)
 
yes there are limitations

and there is a problem - instead of throwing an error it performs the insert :-(
in 8.0 it is fixed obviously (in 7.4 I don't know)
I can't thing of better solution except upgrading :-(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top