In Oracle Database, we can use PL/SQL and create stored procedure and functions. As for PostgreSQL, we can use and create function.
Here, we write the way to execute PL/pgSQL on the spot, without creating function.
Continue reading PostgreSQL: Execute PL/pgSQL Code on the Spot