Versions Compared

Key

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

...

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.

There cannot be installed It is not possible to install more than one procedure with the same name, so you may delete a procedure by calling #DROPPROCEDURE before. 


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
languagecql
themeEclipselanguagecql
linenumberstrue
#PROCEDURE setSomething
varX
attribute
BEGIN
    #RUNQUERY
    SELECT 1 AS a, 2 AS ${attribute}, * FROM bid WHERE b>${varX}
END

...

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


Example

This example concludes the one from #PROCEDURE. Therefore we have two parameters (varX and attribute). The following executes the "setSomething" procedure and sets varX=1 and attribute=b.

Code Block
language
languagejavascript
themeEclipse
javascriptlinenumberstrue
#EXECUTE setSomething(1, b)

The variables are replaced and the according Odysseus Script of the procedure is executed at this point. Therefore, the following is inserted insted of the #EXECUTE command:

Code Block
language
languagejavascript
themeEclipse
javascriptlinenumberstrue
    #RUNQUERY
    SELECT 1 AS a, 2 AS b, * FROM bid WHERE b>1

Since this snippet is simply inserted, all things of the surrounding Odysseus Script is taken. In our example, this is for example, the choosen #PARSER and #TRANSCFG that are necessary for #RUNQUERY here. Therefore, it is not guaranteed that a procedure is executable of its own.

 


#DROPPROCEDURE

The command can be used to remove stored procedures, which were created by using the #PROCEDURE (see for more information about procedures) command.

...

You can create the procedure by using the #PROCEDURE command or execute a procedure by calling #EXECUTE 


Example

This example concludes the one from #PROCEDURE. Therefore, we want to remove the "setSomething" procedure:

Code Block
languagejavascript
themeEclipselanguagejavascript
linenumberstrue
#DROPPROCEDURE setSomething