From: Tarlika Elisabeth Schmitz <postgresql4@numerixtechnology.de>
To: pgsql-sql@postgresql.org
Subject: extract some column/value pairs via hstore
Date: Mon, 13 Jun 2011 20:04:54 +0100
Message-ID: <20110613200454.2a903880@dick.coachhouse> (raw)
In a PL/pgSQL function, I need to extract column/value pairs from a
table ignoring some of the columns.
The excluded column names have previously been stored in an array
"ak", which contains
array['country_fk', 'region_fk', 'id']
SELECT key, value FROM
(
SELECT (each(hstore(town))).* FROM town
) AS nk
WHERE key NOT IN (SELECT unnest(ak));
=====
The above statement produces the desired result but it seems a bit
convoluted. Can this be done in a more elegant way?
=====
PostgreSQL 8.4
example:
CREATE TABLE town
(
country_fk character varying(3) NOT NULL,
region_fk character varying(3) NOT NULL,
id serial NOT NULL,
"name" character varying(50) NOT NULL,
source character varying(2) NOT NULL
)
--
Best Regards,
Tarlika Elisabeth Schmitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: postgresql4@numerixtechnology.de
Subject: Re: extract some column/value pairs via hstore
In-Reply-To: <20110613200454.2a903880@dick.coachhouse>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox