Re: how to key/value iterate in stored function

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: "J(dot)V(dot)" <jvsrvcs(at)gmail(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: how to key/value iterate in stored function
Date: 2011-10-12 14:51:47
Message-ID: CAHyXU0zCv2p2yPCVEA6LADD1hHF=_1S1j_QT-GPYfpcx5F=NgA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Oct 12, 2011 at 8:46 AM, J.V. <jvsrvcs(at)gmail(dot)com> wrote:
> I want to create a variable that is an array or list of key/value pairs.
>
> The key would be a table name and the value would be a sql statement or a
> value or list of values for which I could extract to create a sql statement
> and execute.
>
> I have tried experimenting with various arrays, but there is no clear
> example or documentation.  The key and the value would be text.
>
> I want to iterate over the entire array (or list), so would need an example
> on that or some pointers there, if there is help.

use thee the hstore!

postgres=# select * from each('a=>1,b=>2');
key | value
-----+-------
a | 1
b | 2
(2 rows)

(if you do stick with arrays, use unnest() -- it can be built for
older versions if you don't have it).

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andy Colson 2011-10-12 15:42:13 Re: Conceptual Architecture
Previous Message Chris Travers 2011-10-12 14:48:49 Re: Conceptual Architecture