Re: Built-in functions - does an obect exist... - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: Built-in functions - does an obect exist...
Date
Msg-id 20040608194245.GA15498@wolff.to
Whole thread Raw
In response to Built-in functions - does an obect exist...  ("Loftis, Charles E" <charles.loftis@eds.com>)
List pgsql-novice
On Tue, Jun 08, 2004 at 14:08:11 -0500,
  "Loftis, Charles E" <charles.loftis@eds.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.

pgsql-novice by date:

Previous
From: "Loftis, Charles E"
Date:
Subject: Built-in functions - does an obect exist...
Next
From: Michael Guerin
Date:
Subject: invalid page header