| User Defined Functions Empress v8.62 May 2006
--- | ---

  © 1983, 2006 Empress Software Inc.

  All rights reserved. Reproduction of this document in whole or part, by electronic or any other means, is prohibited without written consent from Empress Software Inc.

  RESTRICTED RIGHTS LEGEND

  Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer Software clause at 52.227-7013.

  05/06

  Part #: 001-06-B4-110

  Empress has the ability to incorporate user defined functions, operators, procedures and aggregate functions as User Defined Functions or Persistent Stored Modules. This manual outlines the procedure for the implementation of user defined functions, operators, procedures and aggregate functions.

  ## Table of Contents

  ### CHAPTER 1: Introduction

  | 1.1 | Overview
  | 1.2 | User Defined Functions as SQL Persistent Stored Modules
  | 1.3 | User Defined Functions as Empress Library at the Kernel Level

  ### CHAPTER 2: Persistent Stored Modules

  | 2.1 | Introduction
  | 2.2 | How to Create Persistent Stored Modules

  |  | 2.2.1 | Dynamic Loading Persistent Stored Modules
  |  | 2.2.2 | Static Linking Persistent Stored Modules

  | 2.3 | Persistent Stored Modules SQL Commands
  | 2.4 | Parameter Style
  | 2.5 | Data Type Correspondences
  | 2.6 | Error Messages

  |  | 2.6.1 | Syntax Error Messages
  |  | 2.6.2 | User Error Messages

  ### CHAPTER 3: Define UDF at the Kernel Level

  | 3.1 | Scope of the User Defined Functions
  | 3.2 | Classes of the User Defined Functions
  | 3.3 | User Defined Function Source Files
  | 3.4 | Priority of User Defined Functions
  | 3.5 | Create Standard C Functions

  |  | 3.5.1 | Defining the Keyword
  |  | 3.5.2 | Making an Entry in the User Function Table
  |  | 3.5.3 | Writing the C Routine

  |  |  | 3.5.3.1 | Handling a Variable Number of Arguments
  |  |  | 3.5.3.2 | Returning Error Messages and Null Values

  |  | 3.5.4 | Compiling UDFs and Relinking the Executables

  | 3.6 | Create Data Type Functions

  |  | 3.6.1 | Defining the Keyword
  |  | 3.6.2 | Making an Entry in the User Function Table
  |  | 3.6.3 | Creating the Function I/O Table
  |  | 3.6.4 | Defining Data Type Identifiers
  |  | 3.6.5 | Defining the Function Procedures Table
  |  | 3.6.6 | Writing the C Routine

  |  |  | 3.6.6.1 | Error Handling in DT User Defined Functions
  |  |  | 3.6.6.2 | Null Value Handling in DT User Defined Functions

  |  | 3.6.7 | Compiling UDFs and Relinking the Executables

  | 3.7 | Example Programs

  |  | 3.7.1 | User Defined Function Include File

  |  | 3.7.2 | Standard C User Defined Functions Example Program

  |  |  | 3.7.2.1 | Keyword Definition
  |  |  | 3.7.2.2 | Routines
  |  |  | 3.7.2.3 | Function Tables and Variables

  |  | 3.7.3 | Data Type User Defined Functions Example Program

  |  |  | 3.7.3.1 | Keyword and Type Definition
  |  |  | 3.7.3.2 | Routines
  |  |  | 3.7.3.3 | Structures and Tables

  ### CHAPTER 4: Manual Pages