| From: | Yi Zhao <yi(dot)zhao(at)alibaba-inc(dot)com> |
|---|---|
| To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
| Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: how to found a variable is in a aggregation or not? |
| Date: | 2008-07-16 01:09:07 |
| Message-ID: | 1216170547.3240.0.camel@localhost.localdomain |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
yes!!!!
It's better obviously,
thanks:D
Yi
On Tue, 2008-07-15 at 15:46 +0200, Pavel Stehule wrote:
> 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(dot)zhao(at)alibaba-inc(dot)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(at)postgresql(dot)org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-general
> >
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2008-07-16 01:37:32 | Re: C-procedure crashed in Postgres 8.3.3 when using 'text' variable (WinXP) |
| Previous Message | Scott Marlowe | 2008-07-16 00:46:51 | Re: Out of memry with large result set |