0
@Table(name = "Table")
class Table{
 String a
 Integer b
}

here column a in table t is character varying(32)

I have tried both of these and end-up with error.

SELECT t.b from Table t where Integer.parseInt(t.a) > 0 
Error : Caused by: org.postgresql.util.PSQLException: ERROR: schema "integer" does not exist

SELECT t.b from Table t where (t.a::integer) > 0 
Error : invalid token :: at line <line number>

Thanks

1
  • 4
    Your first solution is getting further, PostgreSQL is refusing it because it doesn't understand Integer.parseInt. I'm surprised your second solution is not working. Could you try SELECT t.b FROM table t WHERE CAST(t.a AS integer) > 0? Commented Feb 1, 2012 at 5:26

1 Answer 1

4

The following query works fine for me.

SELECT t.b FROM table t WHERE CAST(t.a AS integer) > 0 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you @Daniel Lyons for this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.