Обсуждение: How to describe functions.

Поиск
Список
Период
Сортировка

How to describe functions.

От
Mladen Gogala
Дата:
I  would like to write a single query listing all of the function argument
types. I know that I can write a procedure but I would prefer a single
query. The problem is that in pg_proc, the column proargtypes is of the
type "oidvector", which is another name for an array oid[]. The types
are, of course in pg_type table. The problem here is the array handling.
what I would really like is something like this:

select p.proname,(for($i=0;$i<p.pronargs;$i++ { t.typename where
t.oid=p.proargtypes[$i] }
from pg_proc p, pg_type t;

Of course, I am aware that this is a bad syntax but this pseudocode is
the best way to describe what I want to achieve. The issue is the array
handling.


VMSMladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
www.vmsinfo.com




The Leader in Integrated Media Intelligence Solutions




Вложения

Re: How to describe functions.

От
Thomas Kellerer
Дата:
Mladen Gogala wrote on 10.12.2009 22:39:
> I  would like to write a single query listing all of the function argument
> types. I know that I can write a procedure but I would prefer a single
> query. The problem is that in pg_proc, the column proargtypes is of the
> type "oidvector", which is another name for an array oid[]. The types
> are, of course in pg_type table. The problem here is the array handling.
> what I would really like is something like this:
>
> select p.proname,(for($i=0;$i<p.pronargs;$i++ { t.typename where
> t.oid=p.proargtypes[$i] }
> from pg_proc p, pg_type t;
>

If you are on 8.4 you can use:

select proname, pg_catalog.pg_get_function_arguments(oid)
from pg_proc
;

Thomas