Versions Compared

Key

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

...

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.

Code Block
languagecql
themeEclipselanguagecql
linenumberstrue
#LOOP i 0 UPTO 10
    #RUNQUERY
    SELECT ${i} AS b, * FROM bid 
#ENDLOOP

You may also use ${i-1} or ${i+1} (only this two!). For example, this

Code Block
languagecql
themeEclipse
languagecql
linenumberstrue
#LOOP i 2 UPTO 4
    #RUNQUERY
    SELECT ${i-1} AS a, ${i+1} AS b, * FROM bid WHERE b>${i}
#ENDLOOP

is equal to

Code Block
languagecql
themeEclipse
languagecql
linenumberstrue
#RUNQUERY
SELECT 1 AS b, * FROM bid3 WHERE b>2
#RUNQUERY
SELECT 2 AS b, * FROM bid4 WHERE b>3


You may also use an additional offset variable. This offset variable adds a defined value to the current value of the actual loop variable. Following example uses an offset of x = 5:

Code Block
language
languagecql
themeEclipse
cqllinenumberstrue
#RUNQUERY
#LOOP i 2 UPTO 5 WITH x 5
    SELECT ${x} AS b, * FROM bid 
#ENDLOOP

This is equal to:

Code Block
language
languagecql
themeEclipse
cqllinenumberstrue
#RUNQUERY
SELECT 7 AS b, * FROM bid 
SELECT 8 AS b, * FROM bid 
SELECT 9 AS b, * FROM bid 

...

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
languagejavascript
themeEclipse
languagejavascript
linenumberstrue
#DEFINE latencyOn
....
#IFDEF latencyOn
	#TRANSCFG StandardLatency	
#ELSE
	#TRANSCFG Standard
#ENDIF

...

Code Block
#IFSRCNDEF basestream
#INCLUDE ${WORKSPACEPROJECT/}Source.qry
#ENDIF

#IFQDEF/#IFQNDEF

Similar to #IFDEF but checking if a query with the given name is registered in the executor (see command QNAME) . This can be helpful to define queries only if they are not already defined

Code Block
#IFQNDEF myQuery
#QNAME myQuery
#RUNQUERY
<query text>
#ENDIF

#IF

Similar to #IFDEF and #IFSRCDEF but checking an arbitrary expression. This can be helpful to execute a block only if the expression evaluates to true.

...