extract some column/value pairs via hstore

From: Tarlika Elisabeth Schmitz <postgresql4(at)numerixtechnology(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: extract some column/value pairs via hstore
Date: 2011-06-13 19:04:54
Message-ID: 20110613200454.2a903880@dick.coachhouse
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Browse pgsql-sql by date

  From Date Subject
Next Message INDER 2011-06-14 07:17:32 Storage of Indian Language text in postgresql through PHP
Previous Message Gavin Flower 2011-06-12 21:50:16 Re: selecting records X minutes apart