Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
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 can include the title and surname of the to include details specific to each recipient.
Notepanel | ||
---|---|---|
dfdlf;a | ||
| ||
name
GBP |
Friends of the Owl Society |
The 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 be referenced reference in embedded expressions vary according to depend on context.
Statement Language
RulesRules
Anchor | ||||
---|---|---|---|---|
|
The rules for embedding expressions depend on the language of the statement.
Text
All results of embedded expressions are inserted back into the statement, XML and HTML
${…} is the recommended syntax, although the $ can be omited.
${…} 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.
An 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
${…} may also be used to embed expressions in statements, although this usage is discouraged / deprecated.
If the first character of the embedded expression is '=', this character is ignored.
SQL
Same as for Text, except
If is the recommended syntax, although the $ can be omited.
${…} 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 is ‘=', the . 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.
XML
Same as for Text.
HTML
Same as for Text.
JSON
All results of embedded expressions are inserted back into the statement as textJSON
${…} is the required syntax. JSON uses curly brackets, so the $ acts as an escape character.
${…} expressions are recognised inside matching single or double quotes in the statement.An in a statement even when they are inside:
- single quotes
- double quotes.
The embedded expression is ended by the first '}' provided closing curly bracket }
that it is outside matching any single / double quotes quote pairs within the expression.The {…} form of embedded expressions is not valid.
$$
can be used to escape escapes a single $
into in the statement, without marking the start of an embedded expression.
The result of evaluating the expressions is inserted into the statement as text.
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|