Re: Cast Problem - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: Cast Problem
Date
Msg-id 20050811213057.GA95048@winnie.fuhr.org
Whole thread Raw
In response to Re: Cast Problem  (<operationsengineer1@yahoo.com>)
List pgsql-novice
On Thu, Aug 11, 2005 at 02:14:03PM -0700, operationsengineer1@yahoo.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

pgsql-novice by date:

Previous
From:
Date:
Subject: Re: Cast Problem - varchar() problem
Next
From: Tom Lane
Date:
Subject: Re: Forcing WAL switch