Design by Contract and Oracle PL/SQL

Design by contract is a method whose author is Bertrand Mayer also maker of OOPL language Eiffel, developed in 1980’s.
This paper will present application of DBC methodology in Oracle PL/SQL programming language.


DBC is based on principle that in each routine (procedure or function) with standard code, two additional parts – precondition and postcondition need to be asserted. An additional assertion in class is called invariant.

Contract is based on routine’s putting up an obligation to caller (to some other routine) to satisfy conditions of precondition and conditions of invariant, and hers obligation (called routine’s) to satisfy conditions of postcondition and conditions of invariant.

The main idea is quite the reverse of defensive programming methodology where the program code itself must try to verify as much as it can.

The object oriented Eiffel programming language was created to implement Design by Contract. For now, other object-oriented languages don’t support the ideas behind DBC. However, precondition and postcondition are applicable to many programming languages, both object-oriented and otherwise but invariant are applicable only in object-oriented languages.