Re: Determine length of numeric field

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Determine length of numeric field
Дата
Msg-id AANLkTinxqjfVzcv-=8m_tzLjvCpOah7N9UuBgZauMcO0@mail.gmail.com
обсуждение исходный текст
Ответ на Determine length of numeric field  (Tony Capobianco <tcapobianco@prospectiv.com>)
Ответы Re: Determine length of numeric field  (Tony Capobianco <tcapobianco@prospectiv.com>)
Список pgsql-sql
Hello

probably you have to use a explicit cast

postgres=# select length(10::numeric::text);length
--------     2
(1 row)

Regards

Pavel Stehule

2011/2/15 Tony Capobianco <tcapobianco@prospectiv.com>:
> I'm altering datatypes in several tables from numeric to integer.  In
> doing so, I get the following error:
>
> dw=# \d uniq_hits
>    Table "support.uniq_hits"
>   Column   |  Type   | Modifiers
> ------------+---------+-----------
>  sourceid   | numeric |
>  hitdate    | date    |
>  total      | numeric |
>  hitdate_id | integer |
> Indexes:
>    "uniq_hits_hitdateid_idx" btree (hitdate_id), tablespace
> "support_idx"
> Tablespace: "support"
>
> esave_dw=# alter table uniq_hits alter sourceid type int;
> ERROR:  integer out of range
>
> Sourceid should not be more than 5 digits long.  I'm able to perform
> this query on Oracle and would like something similar on postgres 8.4:
>
> delete from uniq_hits where sourceid in (select sourceid from uniq_hits
> where length(sourceid) > 5);
>
> I haven't had much luck with the length or char_length functions on
> postgres.
>
> Thanks.
> Tony
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>


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

Предыдущее
От: Tony Capobianco
Дата:
Сообщение: Determine length of numeric field
Следующее
От: Peter Steinheuser
Дата:
Сообщение: Re: Determine length of numeric field