Re: Cast Problem

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: operationsengineer1(at)yahoo(dot)com
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Cast Problem
Date: 2005-08-11 21:30:57
Message-ID: 20050811213057.GA95048@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Aug 11, 2005 at 02:14:03PM -0700, operationsengineer1(at)yahoo(dot)com wrote:
> Warning: pg_exec(): Query failed: ERROR: Cannot cast
> type character varying to integer in
> /home/home/adodb/drivers/adodb-postgres64.inc.php on
> line 741
> -1: ERROR: Cannot cast type character varying to
> integer

The error tells you what's wrong: the database doesn't know how to
cast a varchar to an integer. A way around that is to cast the
varchar value to text and then to integer, like this:

ORDER BY serial_number::text::integer;

> it there is no error in 7.4.

That's odd -- 7.4.8 gives me the same "cannot cast type character
varying to integer" error as 7.3.10. 8.0.3 works because 8.0 added
the necessary casts. You can use "\dC" in psql to see what casts
are available.

--
Michael Fuhr

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2005-08-11 21:38:23 Re: Forcing WAL switch
Previous Message operationsengineer1 2005-08-11 21:16:52 Re: Cast Problem - varchar() problem