Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 57A641337B96 for ; Tue, 15 Feb 2011 17:09:57 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 67458-07 for ; Tue, 15 Feb 2011 21:09:50 +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 78D121337B94 for ; Tue, 15 Feb 2011 17:09:49 -0400 (AST) Received: (qmail 26579 invoked from network); 15 Feb 2011 21:09:49 -0000 Received: from unknown (HELO ?192.168.1.87?) (192.168.1.87) by 0 with SMTP; 15 Feb 2011 21:09:49 -0000 Subject: Re: Determine length of numeric field From: Tony Capobianco To: pgsql-sql@postgresql.org In-Reply-To: References: <1297802915.1703.13.camel@tony1.localdomain> Content-Type: text/plain; charset="UTF-8" Date: Tue, 15 Feb 2011 16:09:49 -0500 Message-ID: <1297804189.1703.15.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/67 X-Sequence-Number: 35143 Pavel, That's perfect! Thanks. Tony On Tue, 2011-02-15 at 22:04 +0100, Pavel Stehule wrote: > 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 : > > 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 > > >