Name/Value array to table row

From: Michael Moore <michaeljmoore(at)gmail(dot)com>
To: postgres list <pgsql-sql(at)postgresql(dot)org>
Subject: Name/Value array to table row
Date: 2015-12-15 01:20:32
Message-ID: CACpWLjPr70JnLO76v66oMyo=-Cdk7SxkDGwO5fh4w1uRKPmp4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have an array that is a name value pair where the name is the name of a
column in a table. There are about 300 columns. I want to use all of the
name value pairs to construct the table row. I've thought about using jsonb
or hstore. I'm sure I could write some ugly code to do this, but what is
the BEST way to go about this?
I.E
ARRAY
name |value
-----------
animal | 'cat'
lbs | 20

create table animals (animal text, lbs number);
thanks,
Mike

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2015-12-15 01:31:39 Re: Name/Value array to table row
Previous Message Hector Vass 2015-12-14 21:47:33 Re: regexp_replace question/suggestions needed