Create Window statements is used to define a public named window, which enables you to perform a snapshot query of a public window with SQL queries from several locations.
You can use the Create Window statement to define a public named window. You can:
Use a public window in CCL statements in all the same ways you can use a regular named window (see Create Window statement). A public window used in this way must be located in the same project as the CCL queries that use it.
Perform a snapshot query of a public window with SQL queries, from one of several locations:
From Sybase CEP Studio. See "Debug Menu" in the Sybase CEP Studio Guide for more information. This method can only query public windows contained in the main module or submodules of the project currently being worked on.
From external applications using Sybase CEP SDKs or from the c8_client command-line utility. For more information, see the Sybase CEP Integration Guide .
From a database subquery inside a CCL FROM clause. This method of querying a public window treats the public window as if it were a table in an external database. The public window being queried can be located in the same project as the database subquery, or in a different project (however, the Database statement cannot be used to publish data to a public window).
Before querying a public window with a database subquery, you must first create a database service for the project in which the public window is located in the file c8-services.xml. You can then use this service name in place of the database service name within the database subquery. See the Sybase CEP Administration Guide for more information about setting up services.
Using the ReadFromDB and PollFromDB adapters, which are described in the Sybase CEP Integration Guide . As with the database subquery, the adapters treat the public window as a table in an external database, and you must therefore set up the window's project as a database service in the file c8-services.xml before using the adapters to connect to the public window.
Index a public window in a similar manner to a relational database table. Define an index on a public window on a single column or on multiple columns. Indexing a public window column can significantly improve public window query performance when used with the following SQL operations, either individually or in combination with one another:
column-name = value
column-name < value
column-name > value
column-name <= value
column-name >= value
column-name >= value
ORDER BY expression ASC
Public window indexes do not apply to:
OR operator expressions.
LIKE operator expressions.
Note that, while having a custom index can significantly improve execution time for public window queries, it may also negatively affect performance of your CCL project as a whole. Pay attention to the performance of your project when adding a public window index.
Sybase CEP Engine supports indexes on BLOB and XML columns, but Sybase does not recommend them since BLOB and XML value comparisons are resource-intensive and will negatively affect performance of your CCL project.
All public window queries generate an initial Timestamp column, containing the row timestamp in addition to any columns specified in the query. You can refer to the results of this column in queries of the public window, as in the following example:
INSERT INTO OutStream SELECT Timestamp FROM MyPublicWindow;
Create Schema Statement
Create Window Statement
KEEP
SCHEMA
SQL
CREATE SCHEMA Myschema (Symbol STRING, Price FLOAT, Volume INTEGER, VWAP FLOAT); CREATE PUBLIC WINDOW MyPubWindow SCHEMA Myschema KEEP 1 HOUR PROPERTIES INDEXCOLUMNS = "Symbol, Price";