Re: [SQL] Passing arrays

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Michael Weaver <mweaver(at)corpusglobe(dot)com>, "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>, "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: [SQL] Passing arrays
Date: 2003-02-14 04:14:15
Message-ID: 200302132014.15805.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

Micheal,

> How do you get an array of elements to be passed to a stored proc such that
> you can use the array in a SELECT statement in the WHERE clause
> - e.g. WHERE field IN (array) etc...

There's no easy way, right now. You'll have to:
1) loop through the array and pass its elements to a comma-delimited TEXT
variable.
2) Build up your query as a dynamic string.
3) Do your query loop as a FOR record IN EXECUTE dynamic_query_string

--
Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Stephan Szabo 2003-02-14 04:57:33 Re: [SQL] Passing arrays
Previous Message Michael Weaver 2003-02-14 04:09:44 Passing arrays

Browse pgsql-sql by date

  From Date Subject
Next Message chester c young 2003-02-14 04:38:00 rownum
Previous Message Michael Weaver 2003-02-14 04:09:44 Passing arrays