query_script_statements
QueryScript Statements: operations on data, schema or flow.
SYNOPSIS
List of QueryScript statementsstatement; { statement; statement; }
DESCRIPTION
Statements are actions to be taken. QueryScript supports statements of the following types:
- SQL statements: the usual DML (SELECT, INSERT, ...), DML (CREATE, ALTER, ...) and other various commands (KILL, GRANT, ...)
- Script statements: statements which affect flow and behavior of script
- Statement blocks
SQL statements
Most SQL statements which are accepted by MySQL are also accepted by QueryScript. These include INSERT, UPDATE, DELETE, SELECT, CREATE, DROP, ALTER, SET, FLUSH, and more.
Among the SQL statements which are in particular not allowed within QueryScript are:
- Dynamic SQL statements (PREPARE, EXECUTE, DEALLOCATE)
- Plugin statements (INSTALL, UNINSTALL)
- Stored routines statements (DECLARE, LOOP, ...), for which QueryScript provides substitutes.
Otherwise, any SQL statement which is not allowed to be executed via dynamic SQL cannot be executed via QueryScript.
Execution of a SQL statement modifies the $rowcount and $found_rows variable. See built-in variables.
QueryScript statements
QueryScript adds and recognizes the following statements:
And the following flow control statements : In addition, the transaction statements start transaction, begin, commit, rollback are managed by QueryScript and delegated immediately to MySQL.Statement blocks
Statements can be grouped into blocks by using the curly braces, as follows:
The entire block is considered to be a statement, and is valid for use in flow control structures, such as foreach, if-else, while, loop-while.{ statement; statement; }
Statement delimiters
QueryScript statements are terminates by a semicolon (";"). The last query in a block or script can optionally not be terminated by the semicolon. Thus, the following are valid scripts:
statement
statement;
A block statement ({...}) is not terminated by a delimiter. There is no way to change the delimiter. In particular, QueryScript does not recognize the DELIMITER statement.{ statement; statement }
Comments
Comments are allowed within QueryScript, as follows:
- Multi line comments are recognized by /* ... */
- Single line comments are recognized by -- . Note that there is a space after the two dashes.
set @x := 3; if (@x < 5 /* This is a comment */) { -- A single line comment select 'x is small'; } else { /* Another comment, this time multiline */ select 'x is large'; }