Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id D5C5E1337B90 for ; Tue, 15 Feb 2011 17:14:43 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 86047-05 for ; Tue, 15 Feb 2011 21:14:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from stan.prospectivdirect.com (mail.prospectiv.com [155.212.59.212]) by mail.postgresql.org (Postfix) with SMTP id DD0EA1337B4E for ; Tue, 15 Feb 2011 17:14:35 -0400 (AST) Received: (qmail 27921 invoked from network); 15 Feb 2011 21:14:35 -0000 Received: from unknown (HELO ?192.168.1.87?) (192.168.1.87) by 0 with SMTP; 15 Feb 2011 21:14:35 -0000 Subject: Re: Determine length of numeric field From: Tony Capobianco To: pgsql-sql@postgresql.org In-Reply-To: <10590.1297804216@sss.pgh.pa.us> References: <1297802915.1703.13.camel@tony1.localdomain> <10590.1297804216@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" Date: Tue, 15 Feb 2011 16:14:35 -0500 Message-ID: <1297804475.1703.16.camel@tony1.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-1.fc12) Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/69 X-Sequence-Number: 35145 Tom, That's a frighteningly easy solution. Thanks. Tony On Tue, 2011-02-15 at 16:10 -0500, Tom Lane wrote: > Tony Capobianco 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 >