Re: PREPARE query with IN?

From: Ivan Voras <ivoras(at)freebsd(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PREPARE query with IN?
Date: 2009-08-05 23:39:13
Message-ID: h5d573$9mv$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Filip Rembiałkowski wrote:
> filip(at)filip=# prepare sth(int[]) as select * from ids where id = ANY($1);
> PREPARE
>
> filip(at)filip=# execute sth('{1,2,3}');
> id | t
> ----+-------
> 1 | eenie
> 2 | menie
> 3 | moe
> (3 rows)

Thanks!

> 2009/8/6 Ivan Voras <ivoras(at)freebsd(dot)org <mailto:ivoras(at)freebsd(dot)org>>
>
> Is it possible to prepare a query with the IN clause in a meaningful
> way? I could probably do it with a hard-coded number of arguments, like
> "SELECT x FROM t WHERE y IN ($1, $2, $3)" but that kind of misses the
> point of using IN for my needs.
>
> In any case, it would probably be a good idea to add a sentence about it
> on http://www.postgresql.org/docs/8.3/interactive/sql-prepare.html since
> I'm probably not the first one to ask about it :)
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org
> <mailto:pgsql-general(at)postgresql(dot)org>)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
>
>
>
> --
> Filip Rembiałkowski
> JID,mailto:filip(dot)rembialkowski(at)gmail(dot)com
> <mailto:filip(dot)rembialkowski(at)gmail(dot)com>
> http://filip.rembialkowski.net/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message sweta 2009-08-06 04:50:42 Sequence Not created with pg_dump
Previous Message Filip Rembiałkowski 2009-08-05 23:17:08 Re: explicit JOIN faster than implicit?