dbTalk Databases Forums  

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

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Built-in functions - does an obect exist... in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Loftis, Charles E
 
Posts: n/a

Default Built-in functions - does an obect exist... - 06-08-2004 , 02:08 PM






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?

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #2  
Old   
Bruno Wolff III
 
Posts: n/a

Default Re: Built-in functions - does an obect exist... - 06-08-2004 , 02:42 PM






On Tue, Jun 08, 2004 at 14:08:11 -0500,
"Loftis, Charles E" <charles.loftis (AT) eds (DOT) com> wrote:
Quote:
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.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.