Hi,
I am using postgresql 7.2.1.
How do i cast an integer value to boolean? I did try the below sequence of
SQLs and was little bit confused, by the way it behaves. It casts the
integer value to boolean in one case but not ever again.
bhuvan=> SELECT count(*)::int::boolean from my_table;
ERROR: Cannot cast type 'integer' to 'boolean'
bhuvan=> -- The SQL similar to the above SQL is my requirement
bhuvan=> SELECT true where (1);
ERROR: WHERE clause must return type boolean, not type integer
bhuvan=> SELECT true where (1::boolean);bool
------t
(1 row)
bhuvan=> SELECT true where (1::int::boolean);
ERROR: Cannot cast type 'integer' to 'boolean'
bhuvan=>
I donot know whether i am wrong or its a bug. I request someone to correct
me if i am wrong or please suggest me the right way to cast an integer to
boolean as, returning true for non-zero value, false otherwise.
regards,
bhuvaneswaran