informix
Informix Guide to SQL: Syntax
SQL Statements

CREATE FUNCTION FROM

Use the CREATE FUNCTION FROM statement to access a user-defined function. The actual text of the CREATE FUNCTION statement resides in a separate file.

Syntax

Element Purpose Restrictions Syntax
file Pathname and filename of the file that contains the full text of a CREATE FUNCTION statement The default pathname is the current directory. The specified file must exist. The file that you specify can contain only one CREATE FUNCTION statement. Pathname and filename must conform to the conventions of your operating system.
file_var Name of a program variable that holds the value of file The file that is specified in the program variable must exist. The file that you specify can contain only one CREATE FUNCTION statement. Name must conform to language-specific rules for variable names.

Usage

An ESQL/C program cannot directly create a user-defined function. That is, it cannot contain the CREATE FUNCTION statement. However, you can create these functions within an ESQL/C program with the following steps:

  1. Create a source file with the CREATE FUNCTION statement.
  2. Use the CREATE FUNCTION FROM statement to send the contents of this source file to the database server for execution.
  3. The file that you specify in the file parameter can contain only one CREATE FUNCTION statement.

For example, suppose that the following CREATE FUNCTION statement is in a separate file, called del_ord.sql:

In the ESQL/C program, you can access the delete_order() SPL function with the following CREATE FUNCTION FROM statement:

If you are not sure whether the UDR in the file is a user-defined function or a user-defined procedure, use the CREATE ROUTINE FROM statement.

The filename that you provide is relative. If you provide a simple filename (as in the preceding example), the client application looks for the file in the current directory.

Important: The ESQL/C preprocessor does not process the contents of the file that you specify. It just sends the contents to the database server for execution. Therefore, there is no syntactic check that the file that you specify in CREATE FUNCTION FROM actually contains a CREATE FUNCTION statement. However, to improve readability of the code, Informix recommends that you match these two statements.

Related Information

Related statements: CREATE FUNCTION, CREATE PROCEDURE, CREATE PROCEDURE FROM, and CREATE ROUTINE FROM


Informix Guide to SQL: Syntax, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved