Lists: | pgsql-sql |
---|
From: | Vad N <vadimid(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | prepared statements |
Date: | 2011-12-07 23:04:07 |
Message-ID: | CAPuKw9Rp=z=o1GO8fdBJbedjHOc8p-CTYeuV8O9Fz+yWVWNUjQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Hi.
How can i pass a set of values to prepared statement?
example
I have a prepared query:
select * from users in ( $1 )
i would like to pass: 1,2,3,4 and get:
select * from users in ( 1,2,3,4 )
Any ideas?
From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Vad N <vadimid(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: prepared statements |
Date: | 2011-12-08 07:40:04 |
Message-ID: | CAFj8pRC2K3-1UfsvQ6ZQ3HjqxKoC6X_gsv-dDqBy3s2P1EJdVA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Hello
2011/12/8 Vad N <vadimid(at)gmail(dot)com>:
>
> Hi.
>
> How can i pass a set of values to prepared statement?
>
> example
> I have a prepared query:
> select * from users in ( $1 )
>
> i would like to pass: 1,2,3,4 and get:
>
> select * from users in ( 1,2,3,4 )
>
> Any ideas?
use a array parameter, please
regards
Pavel Stehule
From: | "David Johnston" <polobo(at)yahoo(dot)com> |
---|---|
To: | "'Pavel Stehule'" <pavel(dot)stehule(at)gmail(dot)com>, "'Vad N'" <vadimid(at)gmail(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: prepared statements |
Date: | 2011-12-08 14:42:58 |
Message-ID: | 050101ccb5b7$aeb96510$0c2c2f30$@yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of Pavel Stehule
Sent: Thursday, December 08, 2011 2:40 AM
To: Vad N
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] prepared statements
Hello
2011/12/8 Vad N <vadimid(at)gmail(dot)com>:
>
> Hi.
>
> How can i pass a set of values to prepared statement?
>
> example
> I have a prepared query:
> select * from users in ( $1 )
>
> i would like to pass: 1,2,3,4 and get:
>
> select * from users in ( 1,2,3,4 )
>
> Any ideas?
use a array parameter, please
regards
Pavel Stehule
------------------------------------------------------------------
Or, in lieu of readily passing arrays from your client API you can always pass a string and modify the query to parse the string into an array.
... users = ANY ( regexp_split_to_array( $1, ',' )::integer[] )
David J.