This page describes Odysseus Script, a language that allows to run (sequences of) queries in different query languages like Continuous Query Language (CQL) or Procedural Query Language (PQL) and to configure the system.
Structure
Variables
Variables
Control Flows
Commands
Each command in Odysseus Script begins with a hash/number sign (#) followed by its name and, finally, by some parameters (if the command needs some parameters).
#COMMAND parameter1 parameter2
Normally, one command is executed for its own and has no impact to other commands. However, the #QUERY command needs current settings like the parser, which is set by the command #PARSER or the transformation configuration, which is set by the command #TRANSCFG.
Comments
Comments are defined for single lines by using three slashes
///this is ignored by the parser
Examples
Control Flows
There are some control flows that allows to define how certain commands are executed.
#LOOP
This control flow allows a simple for-loop, which may be used to execute the same queries or commands two or more times.
Usage
The loop begins with a #LOOP command that needs some parameters and ends with #ENDLOOP. The LOOP command's syntax is as follows
<counter-name> <counter-start> UPTO <counter-end>
where <counter-name> is a string containing a variable. <counter-start> and <counter-end> are integers and defines that the loop starts with <counter-start> (inclusively) and runs until <counter-end> (exclusivly). Therefore, the loop repeats the commands between #LOOP and #ENDLOOP <counter-end> - <counter-start> times. Furthermore, the counter can be used like a variable that was set using #DEFINE.
Example
The examples shows a loop that repeats 10 times (i=0 until i<10) and executes the "#RUNQUERY SELECT ..." accordingly ten times. Furthermore, the counter "i" is used within the query, so that each ${i} is replaced by the current value of i from the loop.
#LOOP i 0 UPTO 10 #RUNQUERY SELECT ${i} AS b, * FROM bid #ENDLOOP
#IFDEF
With #IFDEF it is possible to check whether a variable exists and was set by #DEFINE or not. This is useful, for example, to run certain queries corresponding to the current setting.
Usage
Like common if-statements in other programming languages, the structure of #IFDEF follows "if-then-else", where the "else" part is not necessary. Accordingly, the structure is as follows:
#IFDEF <variable-name>
<then-commands>
#ENDIF
or
#IFDEF <variable-name>
<then-commands>
#ELSE
<else-commands>
#ENDIF
So, if the variable named <variable-name> exists, the control flow runs the <then-commands>, if not and there is an else-part, the <else-commands> are executed. Look also add #DEFINE and #UNDEF to set or unset variables.
Example
The example defines a variable called latencyOn and uses the #IFDEF command to use either StandardLatency for the transformation configuration, if latencyOn is set or Standard if it is not set. Obviously, this example uses allways the <then-command>-part (since latencyOn is set), so you may switch to another transformation config by simply commenting the #DEFINE command out so that the <else-commands> are used.
#DEFINE latencyOn .... #IFDEF latencyOn #TRANSCFG StandardLatency #ELSE #TRANSCFG Standard #ENDIF
Commands
#PARSER
This command sets the current parser for following commands, e.g. by #QUERY or ADDQUERY. The according parser is used until another parser is set.
Parameters
The parser: Which parsers are available strongly depends on the current system setting and installed features. Normally in the default product, there is "PQL" for Procedural Query Language (PQL) and "CQL" for Continuous Query Language (CQL).
Example
#PARSER PQL
#QUERY
This command sets the current parser for following commands, e.g. by #QUERY or ADDQUERY. The according parser is used until another parser is set.
Parameters
The parser: Which parsers are available strongly depends on the current system setting and installed features. Normally in the default product, there is "PQL" for Procedural Query Language (PQL) and "CQL" for Continuous Query Language (CQL).
Example
#PARSER PQL
#TRANSCFG
This command sets the transformation configuration for following commands. The transformation configuration defines how a query is transformed into an executable plan. The transformation configuration that was set is used until another configuration is explicitly set.
Parameters
The configuration: Which configruations are available strongly depends on the current system setting and installed features. Normally in the default product, there is "Standard" for the default transformation configuration. If the latency feature is installed, there is also "StandardLatency" available, which invokes specific transformations so that the latency is automatically calculated.
Example
#TRANSCFG Standard