Обсуждение: Arrya variable as argument to IN expression

Поиск
Список
Период
Сортировка

Arrya variable as argument to IN expression

От
Emil Kaffeshop
Дата:
Hello I am trying the following:
a INTEGER[] := ''{10,15,20}'';
b INTEGER := 15;
flag BOOLEAN := FALSE;

SELECT b IN (a) INTO flag; !!! does not work

Is it legal to expect the array to be interpret as
list of integers which IN expression takes ?

Best Regards
Emil kafegiiski


    
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: Arrya variable as argument to IN expression

От
Achilleus Mantzios
Дата:
O Emil Kaffeshop έγραψε στις Nov 17, 2005 :

> Hello I am trying the following:
> a INTEGER[] := ''{10,15,20}'';
> b INTEGER := 15;
> flag BOOLEAN := FALSE;
> 
> SELECT b IN (a) INTO flag; !!! does not work

contrib/intarray and
SELECT intset(b) ~ a::int[] INTO flag;
are your friends.

> 
> Is it legal to expect the array to be interpret as
> list of integers which IN expression takes ?
> 
> Best Regards
> Emil kafegiiski
> 
> 
> 
>         
> __________________________________ 
> Yahoo! FareChase: Search multiple travel sites in one click.
> http://farechase.yahoo.com
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
> 

-- 
-Achilleus



Re: Arrya variable as argument to IN expression

От
"A. Kretschmer"
Дата:
am  17.11.2005, um  0:28:51 -0800 mailte Emil Kaffeshop folgendes:
> Hello I am trying the following:
> a INTEGER[] := ''{10,15,20}'';
> b INTEGER := 15;
> flag BOOLEAN := FALSE;
> 
> SELECT b IN (a) INTO flag; !!! does not work

Sorry, i can't understand your query.

Perhaps you are searchfing for something like:

test=# select * from foo;   a    | b | flag
---------+---+------{1,2,3} | 1 | t{5,6,7} | 1 | t
(2 rows)

test=# select * from foo where b = any(a);   a    | b | flag
---------+---+------{1,2,3} | 1 | t
(1 row)


> 
> Is it legal to expect the array to be interpret as
> list of integers which IN expression takes ?

Please read http://www.postgresql.org/docs/8.1/interactive/arrays.html
to learn more about arrays.


HTH, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net===    Schollglas Unternehmensgruppe    === 


Re: Arrya variable as argument to IN expression

От
Tom Lane
Дата:
Emil Kaffeshop <emildg@yahoo.com> writes:
> SELECT b IN (a) INTO flag; !!! does not work

> Is it legal to expect the array to be interpret as
> list of integers which IN expression takes ?

No.  But try "b = any (a)".
        regards, tom lane