Skip site navigation (1) Skip section navigation (2)

Re: CAST and timestamp

From: Mike G <mike(at)thegodshalls(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: CAST and timestamp
Date: 2004-12-21 04:33:04
Message-ID: 1103603584.5304.32.camel@localhost.localdomain (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Whatever RedHat is paying you it isn't enough.  

Mon, 2004-12-20 at 22:14, Tom Lane wrote:
> Mike G <mike(at)thegodshalls(dot)com> writes:
> > If you want to go from char / varchar to numeric or date types then you
> > need to cast them as text first and then the final data type.
> BTW, to enlarge on this a bit:
> The conversion functions that are actually supplied in pg_cast go from
> text to float4 or timestamp.  In many situations Postgres will
> automatically use these same functions for conversions from varchar or
> char, because it knows that the latter datatypes are just about the same
> as text.  However, in a scenario where you explicitly specify a cast,
> the system will insist on finding an exact match to the requested type
> conversion in pg_cast --- this is so that you can be sure that you get
> exactly the coercion you asked for, and not some surprising variant.
> If you want, you can add entries to the pg_cast catalog to allow direct
> coercions from varchar in all the same places where text can be
> converted.  I'd not recommend treating char the same, since it's really
> not quite the same thing (trailing blank suppression and all that).
> 			regards, tom lane

In response to


pgsql-novice by date

Next:From: Christopher Kings-LynneDate: 2004-12-21 05:58:14
Subject: Re: [PERFORM] Postgres version change - pg_dump
Previous:From: Tom LaneDate: 2004-12-21 04:14:37
Subject: Re: CAST and timestamp

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group