Connecting Tech Pros Worldwide Help | Site Map

Conditional delete

  #1  
Old November 23rd, 2005, 03:04 AM
Bartosz Jakubiak
Guest
 
Posts: 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
  #2  
Old December 8th, 2005, 09:45 AM
Bartosz Jakubiak
Guest
 
Posts: n/a

re: Conditional delete


Bartosz Jakubiak napisal(a):[color=blue]
> 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.[/color]

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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
add or delete a record jmarcrum answers 1 February 16th, 2008 03:50 AM
Conditional Delete of Duplicate Records from Access AccessHunter answers 7 November 5th, 2007 04:52 PM
Conditional Delete buttons - c# JC answers 3 November 18th, 2005 03:38 AM
conditional delete Dee answers 1 November 12th, 2005 07:39 PM