| From: | Viatcheslav Kalinin <vka(at)ipcb(dot)net> |
|---|---|
| To: | Lee Keel <lee(dot)keel(at)uai(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: tables not in list |
| Date: | 2007-07-31 14:15:50 |
| Message-ID: | 46AF4416.90707@ipcb.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Lee Keel | 2007-07-31 14:18:42 | Re: tables not in list |
| Previous Message | Lee Keel | 2007-07-31 13:56:29 | Re: tables not in list |