Re: Creating a function if it's not there in Postgres

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Robert James <srobertjames(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Creating a function if it's not there in Postgres
Date: 2007-05-18 18:22:03
Message-ID: 464DEECB.1000003@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Robert James wrote:
> I use a set of DDL scripts to automatically create the database for an app.
>
> I need to create certain functions (from contrib), if they're not there
> already. If they are there, I don't want to DROP or REPLACE them, since
> they may be used in certain indexes and triggers.
>
> Is there a way to only CREATE a function if it is not defined already?
> Is there a simple way to see if the function is defined?
>
> (I don't want to just try creating it and letting it fail, since the DDL
> runs in a transaction).

instead of create use CREATE OR REPLACE

>
> Thank you.
>

--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2007-05-18 18:26:49 Re: Large Database Restore
Previous Message Robert James 2007-05-18 18:17:12 Creating a function if it's not there in Postgres