![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
Mladen Gogala wrote: 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: You mean something like that? SELECT p.proname, (SELECT array_agg(t.typname) FROM unnest(p.proargtypes) AS o(oid) JOIN pg_type AS t ON (o.oid=t.oid)) AS argtypes FROM pg_proc AS p; Yours, Laurenz Albe |
#4
| |||
| |||
|
|
Mladen Gogala wrote: 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. You mean something like that? SELECT p.proname, (SELECT array_agg(t.typname) FROM unnest(p.proargtypes) AS o(oid) JOIN pg_type AS t ON (o.oid=t.oid)) AS argtypes FROM pg_proc AS p; Yours, Laurenz Albe |
![]() |
| Thread Tools | |
| Display Modes | |
| |