Re: Determine length of numeric field

From: Tony Capobianco <tcapobianco(at)prospectiv(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Determine length of numeric field
Date: 2011-02-15 21:14:35
Message-ID: 1297804475.1703.16.camel@tony1.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom,
That's a frighteningly easy solution.
Thanks.
Tony

On Tue, 2011-02-15 at 16:10 -0500, Tom Lane wrote:
> Tony Capobianco <tcapobianco(at)prospectiv(dot)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
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Stosberg 2011-02-15 22:04:52 recommended data model for a search?
Previous Message Tom Lane 2011-02-15 21:10:16 Re: Determine length of numeric field