Re: proposal: plpgsql - iteration over fields of rec or row variable - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: proposal: plpgsql - iteration over fields of rec or row variable
Date
Msg-id AANLkTin_FJU+36zBNA-DXQiQA3xWoBFvMvgHL_ZpVoFt@mail.gmail.com
Whole thread Raw
In response to Re: proposal: plpgsql - iteration over fields of rec or row variable  ("David E. Wheeler" <david@kineticode.com>)
Responses Re: proposal: plpgsql - iteration over fields of rec or row variable
Re: proposal: plpgsql - iteration over fields of rec or row variable
List pgsql-hackers
2010/11/9 David E. Wheeler <david@kineticode.com>:
> On Nov 9, 2010, at 1:38 AM, Dmitriy Igrishin wrote:
>
>> * text[] = record_to_array(record)
>> * table(id, key, datatype, value) = record_to_table(record)
>> * text = record_get_field(record, text)
>> * record = record_set_field(record, text, anyelement)
>>
>> ??
>> I personally like it. But I propose to add as well:
>>   integer := record_nkeys();
>>   text := record_get_field(record, integer);
>
> You realize you can pretty much do all this with hstore, right?

hstore has similar functionality, but missing a some details and add
lot of other functionality - it doesn't identify type of field.
Personally - it is nothing what I like - but can be better than
nothing.

Pavel


>
>  hstore hash := hstore(record);
>  ary    text[] := hstore_to_matrix(hash);
>  select * from each(hash); -- TABLE
>  text foo := hash -> somekey;
>  hash := hash || '"key","value"'::hstore;
>  record := populate_record(record, hash);
>
> Best,
>
> David
>
>


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: proposal: plpgsql - iteration over fields of rec or row variable
Next
From: "David E. Wheeler"
Date:
Subject: Re: proposal: plpgsql - iteration over fields of rec or row variable