Re: problem with array query - Mailing list pgsql-general

From Tom Lane
Subject Re: problem with array query
Date
Msg-id 12232.1254102178@sss.pgh.pa.us
Whole thread Raw
In response to problem with array query  (Grant Maxwell <grant.maxwell@maxan.com.au>)
Responses Re: problem with array query  (Grant Maxwell <grant.maxwell@maxan.com.au>)
List pgsql-general
Grant Maxwell <grant.maxwell@maxan.com.au> writes:
> According to the 8.3 docs I should be able to write:
> select * from tblretrain where   'ms-ap-t2-02c9' NOT IN   (owners);
> where owners is an array per the following definition
>    owners character varying(1024)[],

No, what you can write is "<> ALL", not NOT IN.

> It seems as though postgres is not recognising owners as an array.

It's trying to parse the literal as an array so that it can do a
plain equality comparison against the owners column.

You probably read the part of the docs where it says that
x NOT IN (SELECT ...) is equivalent to x <> ALL (SELECT ...).
Which is true, but it has nothing to do with the non-sub-SELECT syntax.
Without a sub-SELECT, we have two cases:
x NOT IN (y,z,...) expects x,y,z to all be the same type.
x <> ALL (y) expects y to be an array of x's type.
Got it?

            regards, tom lane

pgsql-general by date:

Previous
From: Grant Maxwell
Date:
Subject: problem with array query
Next
From: Grant Maxwell
Date:
Subject: Re: problem with array query