CREATE MODULE Statement

Create a module that contains specific functionality that you can load in a CCL project using the LOAD MODULE statement.

Syntax

CREATE MODULE moduleName
IN input1 [, ...]
OUT output1[, ...]
[REFERENCES reference1 [, ...]]
BEGIN
	statements;
END;

Components

moduleName

The name of the module.

input1

Specify the first input stream or window. If there are any additional streams or windows, they must follow in a comma-separated list.

output1

Specify the output stream or window. If there are any additional output streams or windows, they must follow in a comma-separated list.

reference1

If there is reference in the module, the reference in the main body of the project, which provides the connection information for the database lookup. If there are additional references in the module the references in the main body of project for each of them must follow in a comma-separated list.

Usage

All CCL statements are valid in a module except:

  • CREATE MODULE
  • ATTACH ADAPTER
  • ADAPTER START GROUPS

The string specifies as the moduleName should be unique across all object names in the scope in which the statement exists. The names in the IN and OUT clauses must match the names of the streams or windows defined in the BEGIN-END block. All streams or windows with input visibility must be listed in the IN clause. All streams, windows, and delta streams (including those created by the flex operator), with output visibility must be listed in the OUT clause. The compiler generates an error if any input or output objects exist in the module and are not listed in their respective IN or OUT clause.

You can use multiple CREATE statements within modules. Some, such as the CREATE WINDOW and CREATE STREAM statements, use the same syntax within a module as they do within the main project. Others, such as the CREATE REFERENCE and CREATE STORE statements use a different syntax within a module than they use within the main project.

The CREATE STORE syntax within a module is:
CREATE [DEFAULT] {MEMORY|LOG} STORE store1-inmodule;
The syntax used within a module does not allow you to specify any store properties as you could within the main project.
The CREATE REFERENCE syntax within a module is:
CREATE REFERENCE name  schema_clause [PRIMARY KEY (column1, column2, ...)];
The syntax within the module does not include connection information because that is obtained from the reference in the main body of the project.
Note: All CREATE MODULE statement compilation errors are fatal.

Restrictions

  • You cannot use the CREATE MODULE statement within the module definition.

Example

This example creates a simple module that filters data based on a column's values:
CREATE MODULE filter_module
IN moduleIn
OUT moduleOut
BEGIN
	CREATE SCHEMA filter_schema (Value INTEGER);
	CREATE INPUT STREAM moduleIn
        SCHEMA filter_schema;
	CREATE OUTPUT STREAM moduleOut
        SCHEMA filterSchema
        AS SELECT * FROM moduleIn
        WHERE moduleIn.Value > 10;
END;