On 17.02.2012 07:33, premanand wrote:
> In MySQL the below query is executing properly.
> SELECT * FROM<Table-name> WHERE (Table.ID LIKE '1%')
> But when i try to execute the above query in Postgres, i get the following
> Exception "org.postgresql.util.PSQLException: ERROR: operator does not
> exist: integer ~~ unknown Hint: No operator matches the given name and
> argument type(s). You might need to add explicit type casts".
> If i convert the same query " SELECT * FROM<Table-name> WHERE CAST(Table.ID
> as TEXT) LIKE '1%' ". This gets executed directly in Postgres DB. But i need
> some query which implicitly type cast in DB, which allows me to execute the
> MySQL query without any Exception. Because i remember there is a way for
> integer to boolean implicit type cast. Please refer the following link.
You can use CREATE CAST
you can create the operator "integer ~~ text" with CREATE FUNCTION +
CREATE OPERATOR. The latter would match fewer cases, which would reduce
the chances of introducing subtle bugs elsewhere in your application.
Of course, the best fix would be to change your queries. It's quite
sloppy to rely on "integer LIKE text" without an explicit cast in the query.
In response to
pgsql-hackers by date
|Next:||From: Etsuro Fujita||Date: 2012-02-17 07:50:50|
|Subject: Re: WIP: Collecting statistics on CSV file data|
|Previous:||From: Jesper Krogh||Date: 2012-02-17 06:09:47|
|Subject: Re: Qual evaluation cost estimates for GIN indexes|