By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

Conditional delete

P: n/a
Hi.

I'm new with PostgreSQL, but this thing doesn't allow me to sleep:

I wonder if it is possible to execute SQL query which:
1. checks out if table exists, and if it is:
2. deletes it
All of it at SQL query level, preferrably in one transaction.

Something like (MSSQL):
IF EXISTS (SELECT * FROM sysobjects WHERE id =
object_id(n'properties_branches') AND objectproperty(id, n'isusertable')
= 1)
DROP TABLE properties_branches

or (MySQL)
DROP TABLE IF EXISTS properties_branches;

Anyone?

Thanks. And sorry if it is a stupid question.

--
Bartosz Jakubiak
Nov 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Bartosz Jakubiak napisal(a):
I wonder if it is possible to execute SQL query which:
1. checks out if table exists, and if it is:
2. deletes it
All of it at SQL query level, preferrably in one transaction.


As far as I know it is not possible in SQL.
You have to use one of procedural languages.
For PostgreSQL 7.4 look here:
http://www.postgresql.org/docs/7.4/static/xplang.html

--
Bartosz Jakubiak
Dec 8 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.