extract some column/value pairs via hstore - Mailing list pgsql-sql

From Tarlika Elisabeth Schmitz
Subject extract some column/value pairs via hstore
Date
Msg-id 20110613200454.2a903880@dick.coachhouse
Whole thread Raw
List 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"
charactervarying(50) NOT NULL, source character varying(2) NOT NULL
 
)

-- 

Best Regards,
Tarlika Elisabeth Schmitz


pgsql-sql by date:

Previous
From: Gavin Flower
Date:
Subject: Re: selecting records X minutes apart
Next
From: Florian Weimer
Date:
Subject: Re: Subselects not allowed?