Based on replies to another post (recommending use of
'generate_series'), I was able to write the following query that
returns all paramters of a given function.
Only one interesting thing to note- in order to return the proper
argument type, I had to use
  proargtypes[i - 1]     when I expected this to work:    proargtypes[i]

Any feedback would be appreciated...


SELECT n.nspname AS name_space,
        p.proname AS function_name,
        p.oid AS function_oid, t.typname AS rettype,
        p.prosrc AS body,
   argument, argument_type
FROM pg_proc p
INNER JOIN (SELECT oid, proargnames[i] AS argument, proargtypes[i-1]
AS argument_type
 FROM
        (SELECT oid, proargnames, proargtypes,
                generate_series(1, array_upper(proargnames,1)) AS i
        FROM pg_proc) s
 ) arg
        ON p.oid = arg.oid
INNER JOIN pg_namespace n
        ON p.pronamespace = n.oid
LEFT OUTER JOIN pg_type t
        ON t.oid = p.prorettype
-- WHERE p.proname =  'func_name'

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to