I'd really like to use an IF
, ELSE
construct and execute multiple statements within the IF
and ELSE
blocks, but I don't wish to save my commands to the database as a stored procedure or function. Can I do this in PostgreSQL?
PostgreSQL – Use PL/pgSQL Outside of Stored Procedures or Functions
plpgsqlpostgresqlstored-procedures
Related Question
- SQL Server 2008 – Stored Procedure Consolidation
- MySQL Stored Procedure Grant Revoked After Alter – Solution
- PostgreSQL – Cannot Create RULE from Stored Procedure
- Execute Stored Procedure Remotely Using Linked Server
- SQL Server – Creating and Using Fulltext Index in Stored Procedures
- Postgresql – Stored Procedure for Vacuum in PostgreSQL
Best Answer
There is the
DO
command for ad-hoc plpgsql execution.But you cannot pass parameters or return rows directly to / from a
DO
command.BTW, strictly speaking, Postgres does not have "stored procedures" before Postgres 11. Just functions providing very similar functionality. See: