Re: tables not in list

From: Lee Keel <lee(dot)keel(at)uai(dot)com>
To: Viatcheslav Kalinin <vka(at)ipcb(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: tables not in list
Date: 2007-07-31 14:18:42
Message-ID: 76758090F8686C47A44B6FF52514A1D308C9C6B8@hermes.uai.int
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: Viatcheslav Kalinin [mailto:vka(at)ipcb(dot)net]
> Sent: Tuesday, July 31, 2007 9:16 AM
> To: Lee Keel
> Cc: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] tables not in list
>
> 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

THANKS! That was exactly what I needed!
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-07-31 14:25:45 Re: Performance problem with large resultsets (byte array 2200)
Previous Message Viatcheslav Kalinin 2007-07-31 14:15:50 Re: tables not in list