Thread: change data type 'money' to '€'

change data type 'money' to '€'

From
Mäggi Hieber
Date:
Hello

In our project table we have a column with costs, using data typ
"money". By default PostgreSQL always applys '$', but we would like to
have '€'.
How can I change the data type "money" (currency) of a column in an
existing table to '€'?

Thanks a lot!
Mäggi

Re: [NOVICE] change data type 'money' to '€'

From
Ognjen Blagojevic
Date:
Hi Mäggi,

On 30.6.2011 17:15, Mäggi Hieber wrote:
> In our project table we have a column with costs, using data typ
> "money". By default PostgreSQL always applys '$', but we would like to
> have '€'.
> How can I change the data type "money" (currency) of a column in an
> existing table to '€'?

It is locale specific thing, defined in variable lc_monetary. If your
locale uses $, it will display $. If you want to display EUR instead,
you will need to set lc_monetary to the country using euros (say, Germany).

You may set lc_monetary in postgresql.conf, or within your sql client.
Here is the latter test case:

create table money_test (
   m money not null,
   primary key(m)
);
insert into money_test values ('123');
set lc_monetary="de_DE@euro";
select * from money_test;

-Ognjen

Re: change data type 'money' to '€'

From
"Jean-Yves F. Barbier"
Date:
On Thu, 30 Jun 2011 17:15:23 +0200, Mäggi Hieber <mhieber@sunrise.ch> wrote:

> In our project table we have a column with costs, using data typ
> "money". By default PostgreSQL always applys '$', but we would like to
> have '€'.
> How can I change the data type "money" (currency) of a column in an
> existing table to '€'?

This is not such a good idea to use currencies' shortcuts, specially if your
program is to be internationalized or used with another currency (eg: there's
no shortcut for Swiss Franc) - for these reasons, you'd better use 3 letters
ISO-4217 codes http://www.xe.com/iso4217.php

--
Body by Nautilus, Brain by Mattel.

Re: change data type 'money' to '€'

From
Tom Lane
Date:
=?ISO-8859-15?Q?M=E4ggi_Hieber?= <mhieber@sunrise.ch> writes:
> In our project table we have a column with costs, using data typ
> "money". By default PostgreSQL always applys '$', but we would like to
> have '�'.
> How can I change the data type "money" (currency) of a column in an
> existing table to '�'?

See the lc_monetary setting (you'll need to have an installed system
locale setting that does what you want).

            regards, tom lane