CREATE LIBRARY Statement

In order to use external C/C++ and Java functions in CCL expressions, you must first declare them in your CCL project using the CREATE LIBRARY statement.

Syntax

CREATE LIBRARY libraryName LANGUAGE {C|JAVA} FROM fileName(
returnType funcName (argType [argName],...);
...);

Components

libraryName

The user-specified name of the library.

C, JAVA Defines the language of the library. The names are case-insensitive.
fileName

For C/C++ functions, the directory of the shared library. You can use a path relative to the current directory.

For Java functions, the name of the class file without the .class suffix. You can specify it as a string parameter. You can use the -j option when starting the Event Stream Processor Server to provide the locations of the class files.

funcName

The name of the declared function.

returnType, argType

Datatype of the return value of the function and an argument of the function, respectively.

argName

The name of an argument of the function.

Usage

Call declared functions using the libraryName.funcName notation.

Use the IMPORT statement to import the CREATE LIBRARY statement from a different CCL file to your main project.

You can reference only one external library using the CREATE LIBRARY statement, but you can reference the external library any number of times in multiple CREATE LIBRARY statements.

Libraries are defined, which means you can use them before they have been declared. However, if a global user-defined function uses an external C/C++ or Java function, you must declare the library, specifying the function signature, before the global DECLARE block.

Note: C/C++ external library calls support all datatypes, namely boolean, integer, long, float, money(n), date, bigdatetime, binary, and string.

Java external library calls support only integer, long, double, and string datatypes.

Complex types such as dictionaries, vectors, event caches and record types are not supported in external functions.

Examples

Create a C/C++ Library

CREATE LIBRARY MyCFunctions LANGUAGE C FROM '/opt/sybase/MyFunctions.so' (
	integer MyFunc1 (integer, integer, float);
	string MyFunc2(string);
);

Create a Java Function

CREATE LIBRARY MyJavaFunctions LANGUAGE JAVA FROM 'MyClass' (
	integer MyFunc1 (integer, integer, float);
	string MyFunc2(string);
);