Sybase CEP provides an RPC plugin that reads the contents of a file in CSV format.
To configure the RPC plugin, modify the related section of the file c8-services.xml, located in the conf subdirectory of your Sybase CEP Server installation directory. The file itself contains comments and an example configuration, and the Sybase CEP Installation Guide provides instructions for enabling RPCs.
Besides the parameters common to all RPC plugins, this plugin uses two additional parameters:
BaseFolder: (Optional). When you call this plugin and specify a file, the file must be located somewhere beneath the base folder specified here. If you do not specify a value for this parameter, Sybase CEP Engine uses the value of the ReadWriteBaseFolder preference specified in c8-server.conf instead.
Format: (Optional). The format of the file, in the form "TitleRow= true | false, TimestampColumn= true | false." The defaults are true and false, respectively.
When you use the plugin in a query, the filename parameter is required. The parameter specifies the path and name of the file to read. Use $BaseFolder to insert the path of the base folder or $ProjectFOlder to insert the path of the folder containing your project. By default, paths are relative to the base folder.
Be aware of the following behaviors when calling this plugin:
The plugin reads the entire CSV file for every row that triggers the query calling the RPC.
The resulting rows have timestamps matching the timestamp of the row that triggers the query calling the RPC. Any timestamps in the CSV file itself are ignored.
This first example shows how to read the file myconfig.csv (located in the same folder as the project file) at startup and populate a window with the contents:
CREATE LOCAL STREAM StartupTrigger SCHEMA (X INTEGER); INSERT INTO StartupTrigger VALUES (1) OUTPUT AT STARTUP; INSERT INTO MyConfigWindow SELECT CsvFile.* FROM StartupTrigger, (REMOTE QUERY "ReadCsvFile" SCHEMA (Name STRING, Value STRING) ( "$ProjectFolder/data/myconfig.csv" as Filename, "TitleRow=false,TimestampColumn=false" as Format ) ) AS CsvFile;
This example shows how to read a file identified by the value of a column in an input stream:
INSERT INTO MyConfigWindow SELECT CsvFile.* FROM (SELECT * FROM ControlStream WHERE Command = "RefreshConfig") as CS , (REMOTE QUERY "ReadCsvFile" SCHEMA (Name STRING, Value STRING) ( CS.Param as Filename, "TitleRow=false,TimestampColumn=false" as Format ) ) AS CsvFile;