Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-07 Thread Dennis Bjorklund
Here is a cast function I wrote some years ago to convert a couple of money columns to numeric http://zigo.org/postgresql/#cast_money_to_numeric You already have a solution, but maybe it is of value to someone else. /Dennis Ken Winter skrev: Right you are, Tom! In case anyone else is fa

Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-07 Thread Ken Winter
nt: Saturday, June 07, 2008 11:25 AM > Subject: Re: [GENERAL] Extracting data from deprecated MONEY fields > ... > If you do it within plpgsql it should work. Just assign the money value > to a text variable (or vice versa). > > regards, tom lane CREA

Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-07 Thread Tom Lane
Tino Wildenhain <[EMAIL PROTECTED]> writes: >> to_char() and back to numeric shouldn't be a problem within the database >> and we have regex too if anything fails. I don't think you need to >> dump and edit the dump to achive that. > Ah sorry forget that... neither to_char nor cast to text works.

Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-07 Thread Tino Wildenhain
Hi, Tino Wildenhain wrote: Hi, Shane Ambler wrote: ... I think the steps Joshua is referring to are - 1. pg_dump -t mytable_with_money mydb > mytable_backup.sql 2. edit table definition in backup file to use numeric 3. remove $ and , from money column data 4. DROP TABLE mytable_with_money 5.

Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-07 Thread Tino Wildenhain
Hi, Shane Ambler wrote: ... I think the steps Joshua is referring to are - 1. pg_dump -t mytable_with_money mydb > mytable_backup.sql 2. edit table definition in backup file to use numeric 3. remove $ and , from money column data 4. DROP TABLE mytable_with_money 5. psql < mytable_backup.sql Wh

Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-06 Thread Shane Ambler
Ken Winter wrote: Thanks, Joshua ~ What you suggest is basically what I'm trying to do. Where I'm stuck is in finding a construct (a CAST or whatever) to turn the existing "money" column data (directly or indirectly) into numeric. I've tried to convert a column named "amount" in the following

Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-06 Thread Adrian Klaver
On Friday 06 June 2008 8:49 am, Adrian Klaver wrote: > On Friday 06 June 2008 8:25 am, Ken Winter wrote: > > Thanks, Joshua ~ > > > > What you suggest is basically what I'm trying to do. Where I'm stuck is > > in finding a construct (a CAST or whatever) to turn the existing "money" > > column data

Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-06 Thread Ken Winter
ERAL] Extracting data from deprecated MONEY fields > > On Friday 06 June 2008 8:25 am, Ken Winter wrote: > > Thanks, Joshua ~ > > > > What you suggest is basically what I'm trying to do. Where I'm stuck is > in > > finding a construct (a CAST or wha

Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-06 Thread Adrian Klaver
#x27;', 'g')::numeric; > > ~ Ken > > > -----Original Message- > > From: Joshua D. Drake [mailto:[EMAIL PROTECTED] > > Sent: Thursday, June 05, 2008 11:22 PM > > To: Ken Winter > > Cc: PostgreSQL pg-general List > > Subject: Re: [GENE

Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-06 Thread Ken Winter
AIL PROTECTED] > Sent: Thursday, June 05, 2008 11:22 PM > To: Ken Winter > Cc: PostgreSQL pg-general List > Subject: Re: [GENERAL] Extracting data from deprecated MONEY fields > > Ken Winter wrote: > > I understand from > > http://www.postgresql.org/docs/8.0/static/datatype-mo

Re: [GENERAL] Extracting data from deprecated MONEY fields

2008-06-05 Thread Joshua D. Drake
Ken Winter wrote: I understand from http://www.postgresql.org/docs/8.0/static/datatype-money.html that the “money” data type is deprecated. Money is no longer deprecated in newer releases (specifically 8.3), although I do think it would be wise to push it to numeric. I think the way to do

[GENERAL] Extracting data from deprecated MONEY fields

2008-06-05 Thread Ken Winter
I understand from http://www.postgresql.org/docs/8.0/static/datatype-money.html that the "money" data type is deprecated. So I want to convert the data from my existing "money" columns into new un-deprecated columns, e.g. with type "decimal(10,2)". But every SQL command I try tells me I can'