Re: how to found a variable is in a aggregation or not?
| От | Pavel Stehule |
|---|---|
| Тема | Re: how to found a variable is in a aggregation or not? |
| Дата | |
| Msg-id | 162867790807150646r24ab101djba6165f3238aa0ed@mail.gmail.com обсуждение исходный текст |
| Ответ на | how to found a variable is in a aggregation or not? (Yi Zhao <yi.zhao@alibaba-inc.com>) |
| Ответы |
Re: how to found a variable is in a aggregation or not?
|
| Список | pgsql-general |
so this code is little bit ugly
you can write faster code
create or replace function anytest(val text)
returns boolean as $$
begin
return val in ('hello', 'world','test');
end;
$$ language plpgsql immutable strict;
Pavel
2008/7/15 Yi Zhao <yi.zhao@alibaba-inc.com>:
> I want to check a variable is in a aggregattion or not, so I create a
> function as below:
>
> create or replace function anytest(val text) returns boolean as $$
> begin
> perform 1 where quote_literal(val) in ('hello', 'world', 'test');
> if not found then
> return false;
> else
> return true;
> end if;
> end;
> $$ language plpgsql;
>
> but when I used, I got the result below, why?
>
> test=# select anytest('world111');
> anytest
> ---------
> f
> (1 row)
>
> test=# select anytest('world');
> anytest
> ---------
> f
> (1 row)
>
>
> any help is appreciated.
>
> regards,
> Zy
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
В списке pgsql-general по дате отправления: