Re: Trunc in Postgres

From: "Amin Schoeib" <aschoeib(at)4tek(dot)de>
To: "Pavel Stehule" <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trunc in Postgres
Date: 2003-09-03 14:15:08
Message-ID: 70DD6153277512439CA4B66956A3098132D081@pdc.4tek-net.4tek.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Your solution works in this example, but when
I take a columnname which type is char(30)
I beome the following error:

ERROR: Cannot cast type character to integer

-----Ursprüngliche Nachricht-----
Von: Pavel Stehule [mailto:stehule(at)kix(dot)fsv(dot)cvut(dot)cz]
Gesendet: Mittwoch, 3. September 2003 15:56
An: Amin Schoeib
Cc: pgsql-general(at)postgresql(dot)org
Betreff: Re: [GENERAL] Trunc in Postgres

You can try

select CAST(cast('0000000000000000000000004' as NUMERIC(20)) AS varchar);

Pavel
>
> Hi,
> Is there an equivalent for the trunc function of Oracle in Postgres???
> I need to trunc(the zeros) a number which is stored as a char with a
> lot of zeros Like that : 0000000000000000000000000000004
>
> In oracle you can make that by trunc(YOUR_COLUMNNAME,0)
>
> Thanxx
>
> Schoeib
>
> 4Tek Gesellschaft für angewandte Informationstechnologien mbH Schoeib
> Amin Tel. +49 (0) 69 697688-132
> Fax. +49 (0) 69 697688-111
> http://www.4tek.de
>
>

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-09-03 14:20:41 Re: Localization (for dates) Oracle vs. Postgresql
Previous Message Tom Lane 2003-09-03 14:13:45 Re: Using oids