Skip to content

Command Tags

jeremywinters edited this page Aug 25, 2017 · 7 revisions

Command Tags

SneaQL commands are embedded in special comment tags in the format

/*-sneaql_command param1 param2-*/

These commands are associated with the SQL statement(s) that follows the tag. SneaQL command tags appear as comments and are ignored by the RDBMS.

SneaQL enables you with the following capabilities:

  • Exiting a SQL script if a condition is met.
  • Storing results of a SQL query into a variable for use in subsequent sneaql statements.
  • Optionally executing (or not executing) a SQL statement based upon the evaluation of a comparison.
  • Parameterizing SQL statements with the values of variables.

Command Usage

  1. Every SQL statement must be preceded by a SneaQL command tag, except when using one of the tags that supports multiple statements.
  2. Command tags are comments from a SQL perspective... and can be used along side other comments and even hints!
  3. A command tag governs everything following it until the next command tag is reached.
  4. Some tags are not associated with SQL statements (such as exit_if).
  5. Expressions can be used in tag parameter references as well as within the actual SQL statements.

Command Tags

  • Tags are enclosed by /*- and -*/
  • Command is always lowercase and must follow the left tag without spaces /*-command parameter-*/

Multiple SQL Statements

Some command tags allow for multiple SQL statements to follow:

Note that the last_statement_rows_affected variable will be set based upon the last statement. This feature is also subject to the behavior of the underlying JDBC driver. Executing multiple statements with one tag has only been successfully tested in Amazon Redshift.