Thread: Please clarify

Please clarify

From
palanivel.kumaran@scandent.com
Date:



Hai,

I need a clarification for the below:

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.

Thanks & Regards
Palanivel P.K

Important Email Information :- The  information  in  this  email is
confidential and may  be  legally  privileged. It  is  intended  solely for
the addressee. Access to  this email  by anyone  else  is  unauthorized.  If
you are not the intended recipient, any disclosure, copying, distribution or
any action taken or omitted to be taken in reliance on it, is prohibited
and may be unlawful. If you are not the intended addressee please contact
the sender and dispose of this e-mail immediately.



Re: Please clarify

From
Christopher Kings-Lynne
Date:
Try selecting from pg_views to see if it exists, then if it does, drop it.

Chris

palanivel.kumaran@scandent.com wrote:
> 
> 
> 
> Hai,
> 
> I need a clarification for the below:
> 
> 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.
> 
> Thanks & Regards
> Palanivel P.K
> 
> Important Email Information :- The  information  in  this  email is
> confidential and may  be  legally  privileged. It  is  intended  solely for
> the addressee. Access to  this email  by anyone  else  is  unauthorized.  If
> you are not the intended recipient, any disclosure, copying, distribution or
> any action taken or omitted to be taken in reliance on it, is prohibited
> and may be unlawful. If you are not the intended addressee please contact
> the sender and dispose of this e-mail immediately.
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster


Re: Please clarify

From
Heikki Linnakangas
Date:
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