Re: how to list or array 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: how to list or array of key value pairs
Date: 2011-10-14 20:35:24
Message-ID: CAHyXU0yxTvzHY1N5jVohxbuum05hS9kV8Yq5SzeCJAZojobpGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 14, 2011 at 3:22 PM, J.V. <jvsrvcs(at)gmail(dot)com> wrote:
> Yes, I have seen this before.
>
> But I need an array of key/value pairs (key is string, value is string) and
> I need to iterate through the array accessing both the key and the value.
>
> I look at this page and it does not translate very well into what I need to
> do.  If there are any specific examples out there, it would be greatly
> appreciated.

you keep getting the same answer because as you described your problem
it does *exactly* what you want to do. so, either you are not
describing the problem well or you are not understanding us:
postgres=# select * from each('a=>1,b=>2');
key | value
-----+-------
a | 1
b | 2
(2 rows)

can be dropped directly into plgsql

for record_variable in select * from each('a=>1,b=>2')
loop
<do stuff>
end loop;

etc. What's the issue?

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-10-14 20:36:17 Re: Confused About pg_* Tables
Previous Message J.V. 2011-10-14 20:22:50 Re: how to list or array of key value pairs