Re: tables not in list - Mailing list pgsql-general

From Viatcheslav Kalinin
Subject Re: tables not in list
Date
Msg-id 46AF4416.90707@ipcb.net
Whole thread Raw
In response to Re: tables not in list  (Lee Keel <lee.keel@uai.com>)
List pgsql-general
Lee Keel wrote:
> Is there no way to do this without doing an insert into another table?
>
I usually resolve this as:
-- this function lets you select from an array
CREATE OR REPLACE FUNCTION "array_to_set" (vaarray anyarray) RETURNS
SETOF anyelement AS
$body$
BEGIN
   FOR I IN COALESCE(ARRAY_LOWER(VAARRAY, 1), 1) ..
COALESCE(ARRAY_UPPER(VAARRAY, 1), 0) LOOP
       RETURN NEXT VAARRAY[I];
   END LOOP;
END
$body$
LANGUAGE 'plpgsql';

select table_name
  from array_to_set(array['test', 'bar', 'foo']) as table_name
  where table_name not in (select table_name from
information_schema.tables where table_catalog='postgres' and
table_type='BASE TABLE' and table_schema='public')

regards

pgsql-general by date:

Previous
From: Lee Keel
Date:
Subject: Re: tables not in list
Next
From: Lee Keel
Date:
Subject: Re: tables not in list