Thread: a set of key/value pairs
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? Please do not point me to this doc: http://developer.postgresql.org/pgdocs/postgres/hstore.html What I am looking for is an example as listed in 1..3 above, and that is not provided in the doc. Regards, J.V.
On 10/20/11 11:53 AM, J.V. 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? in what programming language? in SQL, there aren't 'variables', there are relations, and you don't 'iterate', you query. -- john r pierce N 37, W 122 santa cruz ca mid-left coast
On Thu, Oct 20, 2011 at 1:53 PM, J.V. <jvsrvcs@gmail.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