Re: how to found a variable is in a aggregation or not?

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-15 13:31:56
Message-ID: 1216128716.12728.0.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

it's works,
thanks a lot!

regards,
Yi
On Tue, 2008-07-15 at 13:30 +0200, Pavel Stehule wrote:
> Hello
>
> in this case you must not use quoting
>
> postgres=# create or replace function anytest(val text) returns boolean as $$
> begin
> perform 1 where val in ('hello', 'world', 'test');
> if not found then
> return false;
> else
> return true;
> end if;
> end;
> $$ language plpgsql;
> CREATE FUNCTION
> Time: 3,342 ms
> postgres=# select anytest('hello');
> anytest
> ---------
> t
> (1 row)
>
> Time: 42,034 ms
> postgres=# select anytest('helloa');
> anytest
> ---------
> f
> (1 row)
>
> Time: 0,468 ms
> postgres=#
>
> you have to use quoting only together dynamic sql, etc EXECUTE statement
>
> regards
> Pavel Stehule
>
> 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
> >
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2008-07-15 13:34:43 Re: FAQ correction for Windows 2000/XP
Previous Message Morten Barklund 2008-07-15 13:30:16 Re: Unicode database on non-unicode operating system