| From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: drop table if exists mytable; |
| Date: | 2007-02-10 15:33:11 |
| Message-ID: | 20070210153311.GA2061@KanotixBox |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Anton Melser <melser(dot)anton(at)gmail(dot)com> schrieb:
> Hi,
> I need to do a "drop table if exists" type thing. I realise I can
Install 8.2 or use this function, posted by David Fetter:
--
-- posted by David Fetter
--
CREATE OR REPLACE FUNCTION drop_table(TEXT)
RETURNS VOID
STRICT
LANGUAGE plpgsql
AS $$
BEGIN
BEGIN
EXECUTE 'DROP TABLE ' || $1;
EXCEPTION WHEN UNDEFINED_TABLE THEN
/* do nothing */
RETURN;
END;
RETURN;
END;
$$;
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknow)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Douglas McNaught | 2007-02-10 16:48:31 | Re: Trouble w/plperl sproc on red hat 9 |
| Previous Message | Gurjeet Singh | 2007-02-10 15:22:28 | Re: drop table if exists mytable; |