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.
CREATE LIBRARY libraryName LANGUAGE {C|JAVA} FROM fileName( returnType funcName (argType,...); ...);
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 Linux or Solaris paths, preface the directory with a slash. For Windows paths, preface the directory with a double backslash. For Java functions, the name of the class file without the .class suffix. You can specify it as a string parameter. If running within Studio, specify the location of the class files by setting your CLASSPATH variable. If running outside of Studio, set the Java-classpath option in the project configuration file. |
funcName | The name of the declared function. |
returnType, argType |
Datatype of the return value of the function and an argument of the function, respectively. |
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.
Scalar functions are supported. Aggregate functions are not supported.
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.
Java external library calls support only integer, long, float, and string ESP datatypes.
Complex types such as dictionaries, vectors, event caches and record types are not supported in external functions.
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); );