CHAPTER 1: Introduction




1.1 Overview

Since 1983 Empress has provided developers a capability to extend the range of Query Language and 4GL by adding User Defined Functions (UDFs) that can greatly enhance the flexibility of database applications. User Defined Functions can be written in standard C Programming language to do sophisticated pattern matching, statistical calculations, image and sound manipulation, as well as mathematical or lexical functions. This capability was provided way before the standard was defined. Today, a higher level interface to the User Defined Functions has been defined by the ANSI Standard Committee, which is called the Persistent Stored Modules. Empress supports two interfaces for defining User Defined Functions:

  1. as SQL Persistent Stored Modules (SQL/PSM) in the Data Dictionary (Dynamic link).

  2. as Empress library, by defining function names in the keyword tables at the kernel level (Static link).

The usage of User Defined Functions is the same as built-in functions in Empress. They can be invoked from the Empress SQL, Empress 4GL, Empress Report Writer, Empress Hypermedia and they can also be used in C programs through expressions built with mr expression routines .

This manual describes how to extend the capabilities of Empress by adding of User Defined Functions and Procedures using both SQL/PSM and Empress library methods.

The following conventions are used through out this manual:



1.2 User Defined Functions as SQL Persistent Stored Modules

Persistent Stored Modules is the second addendum to the SQL-92 ANSI/ISO standard. It is further defined in the ANSI/IEC 9075-4:1996, Information Technology - Database Languages - SQL - Part 4: Persistent Stored Modules. In addition of being a powerful application development tool, it also provides the foundation support for the object oriented capabilities in SQL3. Empress follows this stand to implement the Persistent Stored Module feature.

Empress Persistent Stored Modules are a set of dynamically loadable libraries that can contain user-defined functions/procedures and triggers. Functions and procedures (together they are referred to as routines) are packaged into a library, and are stored in the database as a Module. These functions and procedures are stored as objects in the schema, just as tables are. These modules are persistent as they are stored in the database, opposed to being stored in the memory which is a non-persistent media.

Functions and procedures written in C host languages as Persistent Modules can be invoked from SQL statements. New Data Definition Language (DDL) statements have been added to allow easy addition, update and drop of PSM objects.



1.3 User Defined Functions as Empress Library at the Kernel Level

Underneath the PSM implementation is Empress way of creating User Defined Functions, i.e., defining UDFs directly into the kernel. Although PSM is much easier and is the preferable way of creating UDFs, Empress makes kernel level interface available and documented for those users who prefer using this interface. Keeping kernel level interface is also useful for users who are interested in the internal implementation of the Persistent Stored Modules.

There are four source files with template included with Empress distribution to allow developers to:

The source files might need to be modified to include the necessary entries for defining User Defined Functions. For Empress to recognize a function, the modified source files need to be compiled, their produced object files need to be archived in the Empress library, and some executables need to be rebuilt.