Re: Type cast errors in version 9.2 while upgrade

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: "Arun P(dot)L" <arunpl(at)hotmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Type cast errors in version 9.2 while upgrade
Date: 2013-06-18 13:29:18
Message-ID: CAF-3MvNyRNn1LyJzjEL9HxtzZe4YF0DePYqeyjBnPhzKG0Wc9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 18 June 2013 14:38, Arun P.L <arunpl(at)hotmail(dot)com> wrote:

>
> Hi All,
>
> We are doing a postgresql upgrade from version 7.4.30 to 9.2. While
> testing the queries in newer version, the following error is obtained for
> some of the queries which were working fine in older version.
>
> *
>
> "ERROR: operator does not exist: character varying = integer.
>
> HINT: No operator matches the given name and argument type(s). You might
> need to add explicit type casts."
>
>
> When modified the script to add ' '(quotes) to integer values, the queries
> are working fine in 9.2 version also. Is this the best fix for this? or is
> there any other way (adding new type cast??) which will help to overcome
> this without modifying all the queries? Please advise.
> ***
>

The solution is to add an explicit type cast. Whether that's a type cast
from integer to varchar or the other way around depends on your situation.

To cast the type, you can use the standard SQL function CAST() or the
Postgres specific :: cast operator or you can do the cast before the values
enter the query (like you seem to have done by putting quotes around the
integer value).

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2013-06-18 13:30:21 Re: Type cast errors in version 9.2 while upgrade
Previous Message Tim Kane 2013-06-18 13:08:21 Foreign Key constraint violation