Thread: Retype

Retype

From
Rado Petrik
Date:
Hi, 

I have query  " SELECT id_user FROM user WHERE (freg_u & 2 ) > 0 ".

freg_u is type smallint.
Query return this error.  

PostgreSQL query failed: ERROR: Unable to identify an operator '&' for
types 'smallint' and 'integer' You will have to retype this query using
an explicit cast in 

How I retype freg_u to interger ? 
-- 
Rado Petrik <r.p@szm.sk>




Re: Retype

From
Richard Huxton
Date:
On Monday 09 Jun 2003 10:24 am, Rado Petrik wrote:
> I have query  " SELECT id_user FROM user WHERE (freg_u & 2 ) > 0 ".
>
> freg_u is type smallint.

> How I retype freg_u to interger ?
... WHERE (freg_u::integer & 2) ...

Or you could use the more standard but long-winded CAST function

--  Richard Huxton