Search Postgresql Archives

Re: how to key/value iterate in stored function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 12, 2011 at 1:43 PM, J.V. <jvsrvcs@xxxxxxxxx> 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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux