INFORMIX
Informix Guide to SQL: Syntax
Chapter 1: SQL Statements
Home Contents Index Master Index New Book

SQL Statements

External Routine Reference

Use an External Routine Reference when you write an external routine.

Syntax

Element Purpose Restrictions Syntax

language name

The name of the language used to write the external routine

The language name must be the name of a supported external language. (The name of the language must be C.)

Identifier, p.1-966

Usage

The External Routine Reference applies only to external functions and provides the following information about an external routine:

Parameter Style

By default, the parameter style is INFORMIX. If you specify an OUT parameter, the OUT argument is passed by reference.

VARIANT or NOT VARIANT

The VARIANT and NOT VARIANT options apply only to functions. You cannot use VARIANT or NOT VARIANT with procedures.

A variant function does not always return the same value for the same arguments. For example, a function that returns the current date and time or a set of rows from a table is a variant function. In INFORMIX-Universal Server,external functions are variant by default.

A non-variant function always returns the same value when passed the same arguments. To register a non-variant function, add the NOT VARIANT option in the External Routine Reference or in the Routine Modifier clause that is discussed on page 1-1026. If you specify the option in both places, you must use the same option in each.

Example

The following example registers an external function named equal() that takes two values of point data type as arguments. In this example, point is an opaque type that specifies the x and y coordinates of a two-dimensional point.

The function returns a single value of type BOOLEAN. The external name specifies the path to the C shared library where the object code of the function is stored. The external name indicates that the library contains another function, point1_equal, which is invoked while equal(point, point) is executing.

References

In this manual, see the CREATE FUNCTION and CREATE PROCEDURE statements.

For information about how to create and register external routines, see the Extending INFORMIX-Universal Server: User-Defined Routines manual.

Function Name

The Function Name segment specifies the name of a function.

Syntax

Element Purpose Restrictions Syntax

database

The name of the database where the function resides

The database must exist.

Database Name, p. 1-856

dbservername

The name of the server that is home to database. The @ symbol is a literal character that introduces the database server name.

The database server that is specified in dbservername must match the name of a database server in the sqlhosts file.

Database Name, p. 1-856

owner

The user name of the owner of the function

If you are using an ANSI-compliant database, you must specify an owner if you do not own the function.

If you do not specify an owner, the default owner is the current user.

Must conform to the conventions of your operating system.

Usage

In a statement that calls for a Function Name, you can enter an identifier with an optional owner name, database name, and server name. The database and server names allow you to use a function stored on a remote database. A function name with a database name, server name, and owner name is called a fully qualified function name.

The actual name of the function is an SQL identifier.

ANSI
The owner name is case sensitive. In an ANSI database, if you type quotation marks around the name, it is stored as you type it. If you do not use quotation marks, the name is stored as uppercase letters. For more information, see the discussion of case sensitivity in ANSI-compliant databases on page
1-1049.

GLS
If you are using a nondefault locale, you can use characters from the code set of your locale in the names of functions. For more information, see the Guide to GLS Functionality.

Routine Overloading

Due to routine overloading, a function name does not need to be unique in INFORMIX-Universal Server. You can define more than one function with the same name and different parameter lists.

Functions are uniquely identified by their signature. A function's signature includes the following items:

If a function name is not unique, Universal Server uses routine resolution to identify the instance of the function to execute. For information about routine resolution, see the Extending INFORMIX-Universal Server: User-Defined Routines manual.

Qualified Function Name

When you add the database name and server name options, you use a fully qualified function name to specify a remote function. You can use those options under the following conditions:

References

In this manual, see the CALL, CREATE FUNCTION, DROP FUNCTION, DROP ROUTINE, and EXECUTE FUNCTION statements.

For information about how to create and use external routines, see the Extending INFORMIX-Universal Server: User-Defined Routines manual. In the Informix Guide to SQL: Tutorial, see Chapter 14 for information about how to create and use SPL routines.




Informix Guide to SQL: Syntax, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.