pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tony Capobianco <tcapobianco@prospectiv.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Determine length of numeric field
Date: Tue, 15 Feb 2011 16:10:16 -0500
Message-ID: <10590.1297804216@sss.pgh.pa.us> (raw)
In-Reply-To: <1297802915.1703.13.camel@tony1.localdomain>
References: <1297802915.1703.13.camel@tony1.localdomain>

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



view thread (7+ messages)  latest in thread

Message-ID: <10590.1297804216@sss.pgh.pa.us>
Permalink:  ../10590.1297804216@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10590.1297804216@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tcapobianco@prospectiv.com
  Subject: Re: Determine length of numeric field
  In-Reply-To: <10590.1297804216@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox