pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Johnston <polobo@yahoo.com>
To: 'Pavel Stehule' <pavel.stehule@gmail.com>
To: 'Vad N' <vadimid@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: prepared statements
Date: Thu, 8 Dec 2011 09:42:58 -0500
Message-ID: <050101ccb5b7$aeb96510$0c2c2f30$@yahoo.com> (raw)
In-Reply-To: <CAFj8pRC2K3-1UfsvQ6ZQ3HjqxKoC6X_gsv-dDqBy3s2P1EJdVA@mail.gmail.com>
References: <CAPuKw9Rp=z=o1GO8fdBJbedjHOc8p-CTYeuV8O9Fz+yWVWNUjQ@mail.gmail.com>
	<CAFj8pRC2K3-1UfsvQ6ZQ3HjqxKoC6X_gsv-dDqBy3s2P1EJdVA@mail.gmail.com>

-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Pavel Stehule
Sent: Thursday, December 08, 2011 2:40 AM
To: Vad N
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] prepared statements

Hello

2011/12/8 Vad N <vadimid@gmail.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.





view thread (3+ messages)

Message-ID: <050101ccb5b7$aeb96510$0c2c2f30$@yahoo.com>
Permalink:  ../050101ccb5b7$aeb96510$0c2c2f30$@yahoo.com/
Also on:    postgresql.org/message-id/050101ccb5b7$aeb96510$0c2c2f30$@yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: polobo@yahoo.com, pavel.stehule@gmail.com, vadimid@gmail.com
  Subject: Re: prepared statements
  In-Reply-To: <050101ccb5b7$aeb96510$0c2c2f30$@yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox