| From: | Peter Steinheuser <psteinheuser(at)myyearbook(dot)com> | 
|---|---|
| To: | Tony Capobianco <tcapobianco(at)prospectiv(dot)com> | 
| Cc: | pgsql-sql(at)postgresql(dot)org | 
| Subject: | Re: Determine length of numeric field | 
| Date: | 2011-02-15 21:08:52 | 
| Message-ID: | AANLkTim93GXPoT+dgMvomfagPu12xRGtdLuGi6=U3fdD@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-sql | 
In Oracle you never have to cast, in Postgres it's pretty common.
See the doc on String Operators and Functions also:
http://www.postgresql.org/docs/8.4/interactive/functions-string.html
On Tue, Feb 15, 2011 at 3:48 PM, Tony Capobianco <tcapobianco(at)prospectiv(dot)com
> wrote:
> 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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
-- 
Peter Steinheuser
psteinheuser(at)myyearbook(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tony Capobianco | 2011-02-15 21:09:49 | Re: Determine length of numeric field | 
| Previous Message | Pavel Stehule | 2011-02-15 21:04:44 | Re: Determine length of numeric field |