I'm slowly moving from MSSQL to PostgreSQL.
In MSSQL I could call editing of already saved procedure or function, and the administration shell (SQL Server Management Studio) showed me procedure's text, so I did not have to store its source code somewhere in text file.
How to do the same with PostgreSQL the convenient way? I'm using pgAdmin III.
You must own the procedure to use ALTER PROCEDURE . To change a procedure's schema, you must also have CREATE privilege on the new schema. To alter the owner, you must also be a direct or indirect member of the new owning role, and that role must have CREATE privilege on the procedure's schema.
Use SQL Server Management StudioExpand Stored Procedures, right-click the procedure to modify, and then select Modify. Modify the text of the stored procedure. To test the syntax, on the Query menu, select Parse. To save the modifications to the procedure definition, on the Query menu, select Execute.
There're 2 clients included in the official distributions of Postgres - the CLI one psql
and a GUI one pgAdmin
. Both support what you want: for psql
it's \ef
and for pgAdmin
- right-click on function, "Properties", "Code" tab.
It's also a convenient way to edit the code and test it.
1) Extract the code of a required SQL function from pgAdmin.
2) Place the code with the function into file.sql.
3) Create a shell/bat file in the same directory with file.sql:
psql -U postgres dbname < file.sql
4) Place a shortcut for the shell/bat file into a fast panel.
5) Edit the file with your favourite text editor and push the shortcut to update the function.
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