Re: How to check if a Procedure or FUNCTION EXIST

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Edwin UY <edwin(dot)uy(at)gmail(dot)com>, Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: How to check if a Procedure or FUNCTION EXIST
Date: 2025-05-27 21:36:32
Message-ID: 6451fea051cfa5a4bbc15941f1e2082216195d43.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, 2025-05-28 at 03:01 +1200, Edwin UY wrote:
> Probably a dumb question of sorts. 
> I want to check for function and procedure if they exist or not including those
> created by the users as well as system functions
>
> Will querying pg_catalog.pg_proc be enough? Using prokind to check if it is function
> or procedure and proowner whether it is a system function or user-defined?

That would simply be

SELECT pronamespace::regprocedure AS "schema",
oid::regprocedure
FROM pg_proc
WHERE proname = 'whatever';

Yours,
Laurenz Albe

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Edwin UY 2025-05-28 00:22:38 Re: How to check if a Procedure or FUNCTION EXIST
Previous Message Usman Khan 2025-05-27 21:17:22 Re: pgAdmin 4 in web mode on an Ubuntu 20.04 (Focal) system.