First, run SQL Server Management Studio and connect to the Database Engine. Next, under Object Explorer, expand the database in which you have created a procedure, and then expand “Programmability” option. Next, expand “Stored Procedures”, right-click the procedure you want and then select “View Dependencies” option.
To view the list of the stored procedure, you can query the information_schema. routines table. It contains the list of the stored procedure and stored functions created on the database.
Right click on your procedure and select Properties. You'll get the following window. As shown inthe preceding image, go to Permissions tab and click on Search button. On click you'll get a window to select user and roles, click on Browse to select users that require permission and click OK.
\df+ <function_name>
in psql.
\ef <function_name>
in psql. It will give the whole function with editable text.
SELECT prosrc FROM pg_proc WHERE proname = 'function_name';
This tells the function handler how to invoke the function. It might be the actual source code of the function for interpreted languages, a link symbol, a file name, or just about anything else, depending on the implementation language/call convention
use pgAdmin or use pg_proc to get the source of your stored procedures. pgAdmin does the same.
Use \df
to list all the stored procedure in Postgres.
If anyone wonders how to quickly query catalog tables and make use of the pg_get_functiondef()
function here's the sample query:
SELECT n.nspname AS schema
,proname AS fname
,proargnames AS args
,t.typname AS return_type
,d.description
,pg_get_functiondef(p.oid) as definition
-- ,CASE WHEN NOT p.proisagg THEN pg_get_functiondef(p.oid)
-- ELSE 'pg_get_functiondef() can''t be used with aggregate functions'
-- END as definition
FROM pg_proc p
JOIN pg_type t
ON p.prorettype = t.oid
LEFT OUTER
JOIN pg_description d
ON p.oid = d.objoid
LEFT OUTER
JOIN pg_namespace n
ON n.oid = p.pronamespace
WHERE NOT p.proisagg
AND n.nspname~'<$SCHEMA_NAME_PATTERN>'
AND proname~'<$FUNCTION_NAME_PATTERN>'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With