PGError: ERROR: operator does not exist: character = integer

Hi,

I’m using PostgreSql database with the rails application,In a
functionality I’m trying to compare two attributes in a condition, one
is of type varchar and other the Integer. While doing so i’m getting the
error as below.

ActiveRecord::StatementInvalid: PGError: ERROR: operator does not exist:
character = integer

LINE 5: WHERE PART.part_number = UNIT.part_number::INT
^
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.

I can’t change the data type of the columns but I need to compare the
above condition. Can anyone help me out in solving the above.

Thanks in advance.

On Tue, Jan 19, 2010 at 12:19 PM, Ashwin Kumar Sharma
[email protected] wrote:

ActiveRecord::StatementInvalid: PGError: ERROR: operator does not exist:
character = integer

LINE 5: Â Â Â Â Â WHERE PART.part_number = UNIT.part_number::INT
                    ^
HINT: Â No operator matches the given name and argument type(s). You
might need to add explicit type casts.

I can’t change the data type of the columns but I need to compare the
above condition. Can anyone help me out in solving the above.

Uh, did you try following that hint? If it didn’t really register you
might
try googling postgres type cast :slight_smile:

HTH,