How do I store a set of queries inside PostgreSQL so I can easily run it again?
pgadmin, postgresql
Solution
Do you know or did you try stored procedure (well, stored-procedure-like functions) ?
http://www.postgresql.org/docs/9.1/interactive/plpgsql-structure.html
To call it
select <name of function>(<param1>, <param2>) as result;
Problem
I want to save a set of queries (multiple SQL updates) as a single element that I can execute using pgAdmin3 (PostgreSQL 9.1). I know that I can save single SELECTS as views but how about multiple UPDATE queries? Example: ``` BEGIN; UPDATE ...; UPDATE ...; COMMIT; ``` Update: What I looking for is a step-by-step guide of adding a stored procedure using the GUI, not running a SQL query that creates it. So far, I encountered two problems with `"New function..."`: the return type is required and found that NULL is not acceptable, so tried `integer`. Also, set the type to `SQL` but I don't know what exactly to write inside the SQL tab, whatever I try the OK button is still disabled and the statusbar says: Please enter function source code.