Re: Casting Varchar to Numeric

Поиск
Список
Период
Сортировка
От Karel Zak
Тема Re: Casting Varchar to Numeric
Дата
Msg-id 20011127122145.E11641@zf.jcu.cz
обсуждение исходный текст
Ответ на Casting Varchar to Numeric  ("Andy Marden" <amarden@usa.net>)
Список pgsql-general
On Tue, Nov 27, 2001 at 09:55:41AM -0000, Andy Marden wrote:
> Just undertaking a port of a small Data Warehouse-type batch load
> application from Oracle to PostgreSQL. It's common practice in such a system
> to load data into a staging table whose fields are typically all varying
> text. Then the conversion and mapping of the data is done as a second stage
> into the 'proper' tables.
>
> In Oracle, you can put a text field into a numeric field as long as it
> contains a number and teh conversion will be implicit (or you can simply
> specify to_number(value)) to make the conversion explicitly.
>
> In PostgreSQL, it seems that an error is thrown up if an implicit conversion
> is attempted, and the only explicit conversion seems to be to_number(value,
> format) which doesn't do what's needed generically enough.

 If you can't cast it by to_number() in you query (why, are you use COPY?)
 you can try define trigger that cast it internaly by to_number() or
 other way.

          Karel

--
 Karel Zak  <zakkr@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/

 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

В списке pgsql-general по дате отправления:

Предыдущее
От: "Andy Marden"
Дата:
Сообщение: Casting Varchar to Numeric
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Casting Varchar to Numeric