External routine features

External routines provide support for most of the common routine features and support for additional features that are not supported by SQL routines.

The following features are unique to external routines:
Access to files, data, and applications that resides outside of the database
External routines can access and manipulate data or files that reside outside of the database itself. They can also call applications that reside outside of the database. The data, files, or applications might, for example, reside in the database server file system or within the available network.
Variety of external routine parameter style options
The implementation of external routines in a programming language can be done using a choice of parameter styles. Although there might be a preferred parameter style for a chosen programming language, there is sometimes choice. Some parameter styles support passing of additional database and routine property information to and from the routine with the dbinfo structure.
Preservation of state between external function invocations with a scratchpad
External user-defined functions provide support for state preservation between function invocations for a set of values. The state preservation is done with a structure called a scratchpad. The state preservation can be useful for functions that return aggregated values and functions that require initial setup logic such as initialization of buffers.
Call-types identify individual external function invocations
External user-defined functions are invoked multiple times for a set of values. Each invocation is identified with a call-type value that can be referenced within the function logic. For example, there are special call-types for the following function calls:
  • First invocation of a function
  • Data fetching calls
  • Final invocation
Call-types are useful because specific logic can be associated with a particular call-type.