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

**URL:** <https://www.ruby-forum.com/t/pgerror-error-operator-does-not-exist-character-integer/181895>\
**Category:** Rails\
**Created:** [January 19, 2010, 9:19pm UTC](https://www.ruby-forum.com/t/pgerror-error-operator-does-not-exist-character-integer/181895 "2010-01-19T21:19:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f08c70/32.png) [@ashwin](https://www.ruby-forum.com/u/ashwin)\
**Post date:** [January 19, 2010, 9:19pm UTC](https://www.ruby-forum.com/t/pgerror-error-operator-does-not-exist-character-integer/181895/1 "2010-01-19T21:19:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ashwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f08c70/32.png) [@ashwin](https://www.ruby-forum.com/u/ashwin)\
**Post date:** [January 19, 2010, 9:36pm UTC](https://www.ruby-forum.com/t/pgerror-error-operator-does-not-exist-character-integer/181895/2 "2010-01-19T21:36:37Z")

</div>

On Tue, Jan 19, 2010 at 12:19 PM, Ashwin Kumar Sharma  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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`🙂

HTH,
