Re: how to key/value iterate in stored function - Mailing list pgsql-general

From Merlin Moncure
Subject Re: how to key/value iterate in stored function
Date
Msg-id CAHyXU0x6Z4rRtybZe+L7_mJ8O1JxKV5u31pv9Y0dXmLL2F9KDQ@mail.gmail.com
Whole thread Raw
In response to Re: how to key/value iterate in stored function  ("J.V." <jvsrvcs@gmail.com>)
List pgsql-general
On Wed, Oct 12, 2011 at 1:43 PM, J.V. <jvsrvcs@gmail.com> wrote:
> I tried hstore with no luck.
>
> How do I initialize the array?
>
> How do I loop through each key/value pair in a stored function to retrieve
> the key and value for each item in the list?
>
> I need a list of key value pairs.  Any options there?

it's all in the docs:
postgres=# select * from each(hstore(ARRAY['a','b'], ARRAY['1','2']));
 key | value
-----+-------
 a   | 1
 b   | 2
(2 rows)


dont see what's so hard 'bout that. 9.0+ hstore is superior to the
composite type method in every way I can think of unless you are
storing explictly non text value in the type and you are not
transferring the compacted list to the client.  hstore is much more
flexible in terms of getting data in/out, searching, etc.  as a bonus
you have gist indexing if you need it, etc etc.

merlin

pgsql-general by date:

Previous
From: Bob Hatfield
Date:
Subject: Re: Are file system level differential/incremental backups possible?
Next
From: Andy Colson
Date:
Subject: Re: PostGIS: Approximating a house number from street address range