Functions are Data Too (Defunctionalization for PL/SQL)

Torsten Grust • Nils Schweinsberg • Alexander Ulrich

Proceedings of the VLDB Endowment (VLDB 2013), Riva del Garda, Italy, August 2013.

We demonstrate a full-fledged implementation of first-class functions for the widely used PL/SQL database programming language. Functions are treated as regular data items that may be (1) constructed at query runtime, (2) stored in and retrieved from tables, (3) assigned to variables, and (4) passed to and from other (higher-order) functions. The resulting PL/SQL dialect concisely and elegantly expresses a wide range of new query idioms which would be cumbersome to formulate if functions remained second-class citizens. We include a diverse set of application scenarios that make these advantages tangible.

First-class /PLSQL functions require featherweight syntactic extensions only and come with a non-invasive iimplementation – the defunctionalization transformation – that can entirely be built on top of existing relational DBMS infrastructure. An interactive demonstrator helps users to experiment with the “function as data” paradigm and to earn a solid intuition of its inner workings.