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

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply via email to