Re: Determine length of numeric field - Mailing list pgsql-sql

From Tom Lane
Subject Re: Determine length of numeric field
Date
Msg-id 10590.1297804216@sss.pgh.pa.us
Whole thread Raw
In response to Determine length of numeric field  (Tony Capobianco <tcapobianco@prospectiv.com>)
Responses Re: Determine length of numeric field
List pgsql-sql
Tony Capobianco <tcapobianco@prospectiv.com> writes:
> 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);

That seems like a pretty bizarre operation to apply to a number.  Why
not "where sourceid > 99999"?  Or maybe "where abs(sourceid) > 99999"
would be better.
        regards, tom lane


pgsql-sql by date:

Previous
From: Tony Capobianco
Date:
Subject: Re: Determine length of numeric field
Next
From: Tony Capobianco
Date:
Subject: Re: Determine length of numeric field