Re: Please clarify - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Please clarify
Date
Msg-id Pine.OSF.4.61.0505102119450.368341@kosh.hut.fi
Whole thread Raw
In response to Please clarify  (palanivel.kumaran@scandent.com)
List pgsql-hackers
On Tue, 10 May 2005 palanivel.kumaran@scandent.com wrote:

> I need to check for the existence of a user defined view named 'audit_vw'
> and if exists, then i need to delete the same. Please help me to solve the
> issue.

If you don't need to do anything else in the transaction, you could just 
issue "DROP VIEW audit_vw" and see if it succeeds or fails.

If you do need to do something else in the same transaction, you can use 
savepoints:

BEGIN;
SAVEPOINT sp;
DROP VIEW audit_vw;
if it fails: ROLLBACK TO sp;
...
COMMIT;

Ps. This kind of questions are usually discussed on the pgsql-general 
mailing list.

- Heikki


pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: Oracle Style packages on postgres
Next
From: "Merlin Moncure"
Date:
Subject: FW: Views, views, views! (long)