Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
This page is for anyone who needs to embed expressions within wider statements.
Overview
To embed an expression within a statement or text:
- Prefix with
$
- Enclose the expression within curly brackets
${ … }
For example, you can use expressions within the text of an email to include details specific to each recipient.
Panel | ||
---|---|---|
| ||
Dear |
|
Friends of the Owl Society |
Embedded expressions are evaluated at run-time and the results are:
- either inserted back into the outer statement
- or retained as separate parameters according to the rules of the language (text, SQL, XML, JSON); see Statement Language Rules, below.
The variables that you can reference in embedded expressions depend on context.
Statement Language Rules
Anchor | ||||
---|---|---|---|---|
|
The rules for embedding expressions depend on the language of the statement.
Text, XML and HTML
${…} is the recommended syntax, although the $ can be
omitted.
${…} expressions are ignored when they are inside:
- single quotes
- double quotes
- ‘
--
’ comments.
If the first character of the embedded expression is an equals sign =
, this character is ignored.
The embedded expression is ended by the first closing curly bracket }
, regardless of the content of the expression.
The result of evaluating the expression is inserted into the statement.
SQL
${…} is the recommended syntax, although the $ can be
omitted.
${…} expressions are ignored when they are inside:
- single quotes
- double quotes
- ‘
--
’ comments.
The embedded expression is ended by the first closing curly bracket }
, regardless of the content of the expression.
How the result of the evaluating the expression is used depends on the first character of the embedded expression. Where the first character:
- is an equals sign
=
, it is stripped before the expression is evaluated. The result of evaluating the expression is inserted as text into the statement.
This is how to pass a variable representing a table name and then insert something into the table. - is not an equals sign, the result of evaluating the expression is passed as a separate parameter to the JDBC driver.
This is how to pass values to be inserted into a table row.
JSON
${…} is the required syntax. JSON uses curly brackets, so the $ acts as an escape character.
${…} expressions are recognised in a statement even when they are inside:
- single quotes
- double quotes.
The embedded expression is ended by the first closing curly bracket }
that it is outside any single / double quote pairs within the expression.
$$
escapes a single $
in the statement, without marking the start of an embedded expression.
The result of evaluating the expressions is inserted into the statement as text.
borderColor | #7da054 |
---|---|
titleColor | white |
titleBGColor | #7da054 |
borderStyle | solid |
title | Sections on this page |