As we are using sp_helptext [procedure name] to get the SP script in Sqlserver, I need the command that i can use to retrieve a function script from postgresql.
Please help....
As we are using sp_helptext [procedure name] to get the SP script in Sqlserver, I need the command that i can use to retrieve a function script from postgresql.
Please help....
If you are using psql (the commandline interface) you can use \df+
as tobixen has already stated (and which is clearly documented in the manual).
If you need to do this from within a SQL query, take a look a the system information functions. You are looking for pg_get_functiondef()
select pg_get_functiondef(oid)
from pg_proc
where proname = 'your_function';
If you are dealing with overloaded functions having a different number of parameters, you need to include the parameter signature into the name:
select pg_get_functiondef('public.foo(int)'::regprocedure);
select pg_get_functiondef('public.foo(int,int)'::regprocedure);
will retrieve the overloaded versions of the function foo
(one version with a single int parameter, the other version with two int parameters).
At the psql command line it's \df+ foo
, isn't it?
Eventually, select prosrc from pg_proc where proname='foo';