Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The #PROCEDURE allows to create stored procedures that are saved into the data dictionary and can be reused by any other scripts, see #EXECUTE how to use run them.

 

Usage

Example

Usage

First, the name, which must be after the #PROCEDURE in the same line, is defined. After that, there might be an ordered list of variables. The order is important! These variables will be used as the parameters. Finally, there can be any Odysseus-Script code including queries etc. between the BEGIN and END. The only exception are "global" variables. Between BEGIN and END, only variables are allowed that are defined before (after the procedure name).

You can execute the procedure by using the #EXECUTE command or delete a procedure by calling #DROPPROCEDURE

 

Example

The example creates a procedure with name "setSomething" and has two parameters (varX and attribute). Remeber, order is important! The procedure calls a #RUNQUERY-Command including both parameters. See #EXECUTE command how this example is used.

Code Block
themeEclipse
languagejavascript
linenumberstrue
#PROCEDURE setSomething
varX
attribute
BEGIN
    #RUNQUERY
    SELECT 1 AS a, 2 AS ${attribute}, * FROM bid WHERE b>${varX}
END

#EXECUTE

The #EXECUTE command can be used for running installed procedures, which were created by using the #PROCEDURE command.

Usage

The usage is similar to function calls in programming languages like Java. After #EXECUTE the name of procedure with a comma-separated list of its parameters. The parameters must be according to the definition of the procedure. If there were two parameters defined by #PROCEDURE, here are also two parameters needed. Notice, the order is important!

You can create the procedure by using the #PROCEDURE command or delete a procedure by calling #DROPPROCEDURE

 

Example

The example creates a procedure with name "setSomething" and has two parameters (varX and attribute). Remeber, order is important! The procedure calls a #RUNQUERY-Command including both parameters. See #EXECUTE command how this example is 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.

Code Block
themeEclipse
languagejavascript
linenumberstrue
#DEFINE latencyOn
....
#IFDEF latencyOn
	#TRANSCFG StandardLatency	
#ELSE
	#TRANSCFG Standard
#ENDIF#PROCEDURE setSomething
varX
attribute
BEGIN
    #RUNQUERY
    SELECT 1 AS a, 2 AS ${attribute}, * FROM bid WHERE b>${varX}
END

 

Commands

#ADDQUERY

This command executes a query in a certain langauge and is equal to #QUERY

...

Example

The first variable is called "one" and has no value. The second variable is called "two" and has the value "1234". See at Variables or at #IFDEF for examples how to use a variable.

...

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
/// query sharing off
#DOQUERYSHARING false
/// query sharing on
#DOQUERYSHARING true

...

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
/// query rewrite off
#DOREWRITE false
/// query rewrite on
#DOREWRITE true

...

Parameters

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#DROPALLQUERIES

...

Parameters

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#DROPALLSINKS

...

Parameters

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#DROPALLSOURCES

...

Example

This example changes the user to "System" with password "manager"

...

Parameters

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#LOGOUT

...

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#ODYSSEUS_PARAM scheduler_TimeSlicePerStrategy 10

...

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

Code Block
themeEclipse
languagejavascript
linenumberstrue
#PARSER PQL

...

If #QName is defined before, the query will get this name.

Example

The example shows four queries after the parser is set to CQL and the transformation configuration is set to Standard. The first one uses #QUERY and it is executed as a CQL-Query, but not started. The second query is equal to the first one (it still uses CQL and is not started). The third query also uses CQL and the Standard transformation configuration, but is (in contrast to the first and second) started (it is directly running). Then, the parser is switched to PQL, so that the fourth query is parsed by the PQL-Parser and not  by the CQL-Parser anymore.

...

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#RELOADFROMLOG

...

Example

Uses the "Single Thread Scheduler" with a "Round Robin" scheduling strategy

...

Example

Waiting 2 seconds (2000 milliseconds) until the next command is invoked.

...

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#STARTQUERIES

...

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#STARTSCHEDULER

...

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#STOPSCHEDULER

...

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#TRANSCFG Standard

...

Example

Code Block
themeEclipse
languagejavascript
linenumberstrue
#TRANSCFG Standard

...