Re: a set of key/value pairs

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: "J(dot)V(dot)" <jvsrvcs(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: a set of key/value pairs
Date: 2011-10-20 20:21:28
Message-ID: CAHyXU0wQBufOwosnj3AdpVQAhkiV_oCjdMahX=2XAFzdV7rDUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 20, 2011 at 1:53 PM, J.V. <jvsrvcs(at)gmail(dot)com> wrote:
> Does anyone have a specific example of how to:
>    1) create a variable that is a set or array of key value pairs?
>    2) how to populate each element of the array (each element being a key /
> value pair)
>    3) how to iterate through the list or array retrieving each key/value
> pair?

create type pair_t as (key text, value text);

select array[('a', '123'), ('b', '234')]::pair_t[];

select (unnest(array[('a', '123'), ('b', '234')]:: pair_t[])).*;

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message S. Balch 2011-10-20 20:34:58 force JDBC driver fetch / autocommit parameters?
Previous Message Gauthier, Dave 2011-10-20 19:56:35 Re: Reading PG data from MySQL stored procedure