Skip site navigation (1) Skip section navigation (2)

Re: How to transform pg_7.4 function 'to_number' to 8.4 equivalent?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ennio-Sr <nasr(dot)laili(at)tin(dot)it>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to transform pg_7.4 function 'to_number' to 8.4 equivalent?
Date: 2008-10-17 18:43:44
Message-ID: 25414.1224269024@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
Ennio-Sr <nasr(dot)laili(at)tin(dot)it> writes:
> after upgrading from pg_7.4 to pg_8.3  when I run this command:

> psql finanza -c "SELECT titolo, var, pr_chius, pr_aper, \
> diff_aper_ch*(-1) as \"diff. ass.\", \
> to_number(diff_aper_ch*(-1)/pr_aper*100::float(8),'9999.000000') as \"sc. %\" \

to_number works on text arguments.  I suppose you could make this work
like 7.4 by explicitly casting the expression to text, but the whole
thing seems like the wrong approach altogether.  What are you trying to
accomplish --- round the result to six decimal places?  If so, it'd be
better to just cast it to numeric(20,6) or some such.

			regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: Ennio-SrDate: 2008-10-18 16:54:10
Subject: Re: How to transform pg_7.4 function 'to_number' to 8.4 equivalent?
Previous:From: Tom LaneDate: 2008-10-17 18:36:58
Subject: Re: "timestamp without timezone" and at "time zone"

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group