Re: Sqlstatement with !=-1 fails - Mailing list pgsql-general

From Allan Engelhardt
Subject Re: Sqlstatement with !=-1 fails
Date
Msg-id 3BC4B5D4.B77CFF2D@cybaea.com
Whole thread Raw
In response to Sqlstatement with !=-1 fails  ("Dave Cramer" <dave@fastcrypt.com>)
List pgsql-general
Hm, SQL92 like <> for the 'not equal' operator and that parses OK:

test=# select count(*) from foo where c<>-1;
 count
-------
     3
(1 row)

It's probably better to use <> ... I can sort of imagine the parser getting confused in your case...

Don't know if this helps?

Allan.

Dave Cramer wrote:

> Hello,
>
> I get the following error
>
> pl=# select * from person where id !=-1;
> ERROR:  Unable to identify an operator '!=-' for types 'int8' and 'int4'
>         You will have to retype this query using an explicit cast
>
> pl=# select * from person where id =-1;
>  id | name | last_update_time
> ----+------+------------------
> (0 rows)
>
> However this works fine
>
> pl=# select * from person where id != -1;
>
> This looks like a parser error, note the space added in the select that
> works ??
>
> Dave
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

pgsql-general by date:

Previous
From: "Mitch Vincent"
Date:
Subject: Re: kinda newbie - ish question
Next
From: Fran Fabrizio
Date:
Subject: Re: Error Codes?