On Mon, Feb 14, 2005 at 12:47:44PM +0500, Sibtay Abbas wrote:
>
> Is it possible to get the oid of a function on the basis of its name?.
One way is to cast the function name to regproc (or, with arguments,
to regprocedure) and then to oid:
SELECT 'atan'::regproc::oid;
SELECT 'length(text)'::regprocedure::oid;
See "Object Identifier Types" in the documentation for more info:
http://www.postgresql.org/docs/8.0/static/datatype-oid.html
> The scenario which i am currently facing is that i have the function name, now
> i want search the pg_proc system catalog on the basis of the function
> name and retrieve its Oid.
SELECT oid FROM pg_proc WHERE proname = 'funcname';
A function can have multiple records in pg_proc if it can take
different types and/or numbers of arguments, so you might have to
allow for that.
> Another confusion which i am facing is that, I am not sure whether Oid
> of a function is entered in pg_proc system catalog or not. Because i
> am not able to identify any relevant field.
oid is a system column; tools that describe tables usually don't
show system columns. You can query pg_attribute to see all of a
table's columns.
http://www.postgresql.org/docs/8.0/static/ddl-system-columns.html
http://www.postgresql.org/docs/8.0/static/catalog-pg-attribute.html
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/