From: | Kovacs Zoltan Sandor <tip(at)pc10(dot)radnoti-szeged(dot)sulinet(dot)hu> |
---|---|
To: | Carolyn Wong <carolyn(at)kss(dot)net(dot)au> |
Cc: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] SQL Script Question |
Date: | 2000-02-23 12:24:34 |
Message-ID: | Pine.LNX.4.05.10002231123340.14711-100000@pc10.radnoti-szeged.sulinet.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> if <table exists>
> drop table xxx;
>
> How can i write this 'if' condition? Or are there any other ways to
> check this??
This SELECT tells you whether a table exists or not:
SELECT tablename FROM pg_tables WHERE tablename='searched_table_name';
With this you can check the condition. Then you may write a PLPGSQL
function which can decide if there was any found table with
searched_table_name or not, see the PLPGSQL example in the src/plpgsql
library.
Then you may call an SQL function (you should write it first) from the
PLPGSQL function which drops table. As I know, you cannot drop a table
inside a PLPGSQL function (only if you call an external SQL function).
I hope this helps. If not, ask for details.
Regards,
Zoltan
From | Date | Subject | |
---|---|---|---|
Next Message | Jerome ALET | 2000-02-23 13:32:30 | problem with grant/revoke |
Previous Message | Andrzej Mazurkiewicz | 2000-02-23 10:06:13 | RE: [SQL] SQL Script Question |