Re: Built-in functions - does an obect exist...

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "Loftis, Charles E" <charles(dot)loftis(at)eds(dot)com>
Cc: postgres <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Built-in functions - does an obect exist...
Date: 2004-06-08 19:42:45
Message-ID: 20040608194245.GA15498@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, Jun 08, 2004 at 14:08:11 -0500,
"Loftis, Charles E" <charles(dot)loftis(at)eds(dot)com> wrote:
> In many other db systems you can use built in functions to check to see if
> an object exists in the db...
>
> For example, in Sybase, you can use the object_id function to check to see
> if an object exists...
> if object_id('some table, view, stored procedure, etc. name') is not null
> -- perform some action, like drop a stored proc
> else
> -- perform some other action
> End -- if
>
>
> Does an equivalent function exist in Postgres?
> Furthermore, where should I look to find the list of such built-in
> functions?

The system catalog and the information schema have metadata about objects.
You can query those tables to find out if an object with a particular name
currently exists. The logic for what to do depending on what is found
will probably need to be in your application or in a function. Straight
SQL is pretty limited for providing conditional code execution.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Guerin 2004-06-09 13:29:12 invalid page header
Previous Message Loftis, Charles E 2004-06-08 19:08:11 Built-in functions - does an obect exist...