Placing query output into psql variables

It is also possible to store some values produced by a query into variables, for instance to reuse them later in other queries.

In this recipe we demonstrate this approach with a concrete example.