Re: Problems with to_number

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Problems with to_number
Date: 2011-06-10 21:08:18
Message-ID: isu13p$5io$1@dough.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chrishelring wrote on 10.06.2011 22:45:
> HI all,
>
> below is the view i´ve tried to create on a table. The purpose was to do
> some math on one of the columns (retning). The column is a double precision
> number. The result is that the function is not recognized ("ERROR: function
> to_number(double precision, unknown) does not exist"). I´m a bit uncertain
> on how the syntax is, so perhaps someone could point me in the right
> direction?

If the column is already a numeric data type there is no reason to use to_number() (which converts a character value to a number)

CREATE OR REPLACE VIEW "husnr_view" ("KOMNR", "VEJKODE", "VEJNAVN",
"HUSNUMMER", "POSTNR", "POSTNAVN", "X", "Y", "RETNING", "TSTAND", "NKLASSE")
AS
SELECT
HUSNR.KOMNR KOMNR,
HUSNR.VEJKODE VEJKODE,
HUSNR.VEJNAVN VEJNAVN,
HUSNUMMER,
HUSNR.POSTNR POSTNR,
HUSNR.POSTNAVN POSTNAVN,
HUSNR.X X,
HUSNR.Y Y,
CASE
WHEN HUSNR.RETNING < 20000 THEN (20000- HUSNR.RETNING)/111
WHEN HUSNR.RETNING > 20000 THEN (40000- (HUSNR.RETNING -20000))/111
END RETNING,
HUSNR.TSTAND TSTAND,
HUSNR.NKLASSE NKLASSE
FROM rk_grundkort.husnr;

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Zhidong She 2011-06-11 10:55:33 PostgreSQL 9.0 users
Previous Message Chrishelring 2011-06-10 20:45:46 Problems with to_number