JDBC Escape Syntax is Java syntaxes sugar on top of SQL.
It's a templating function that permits to translate SQL clause into the different database SQL flavor.
In the examples below, we use the question mark ?. It's known as a parameter
For example, you can call a stored procedure with this escaped SQL syntax
{call procedure_name (?, ?)}
and it will be translated by the database (not by tabulify) to:
BEGIN procedure_name(?, ?); END;
EXEC procedure_name ?, ?
CALL procedure_name(?, ?)
The escape syntax to call a stored procedure is:
{call <procedure_name> [(<argument-list>)]}
{call procedure_name (?, ?)}
or, where a procedure returns a result parameter:
{? = call <procedure_name> [(<argument-list>)]}
{? = call procedure_name (?, ?)}
The escape syntax to access a scalar function is:
{fn <function-name> (argument list)}
For example,
-- called as procedure
{fn concat("Hello", " ", "World")}
-- called with a select
select {fn concat("Hello", " ", "World")}
-- called as procedure
{fn user()}
-- called with a select
select {fn user()}
{fn SUBSTRING(text, 1, 10)}
{fn upper( ? ) }
They get translated into database-specific functions
"Hello" || " " || "World" -- Oracle concat
SUBSTR(text, 1, 10) -- Oracle substring
"Hello" + " " + "World" -- SQL Server concat
SUBSTRING(text, 1, 10) -- SQL Server substring
{d 'yyyy-mm-dd'} -- date
{t 'hh:mm:ss'} -- time
{ts 'yyyy-mm-dd hh:mm:ss.f...'} -- timestamp
Example:
select {d '2023-12-25'} // Date
select {t '14:30:00'} // Time
select {ts '2023-12-25 14:30:00'} // Timestamp
This syntax gets translated to database-specific format
DATE '2023-12-25' -- Oracle Date
'2023-12-25' -- SQL Server Date
The escape syntax for an outer join is:
{oj <outer-join>}
where outer-join has the form:
table {LEFT|RIGHT|FULL} OUTER JOIN {table | <outer-join>} ON search-condition
Example:
SELECT * FROM {oj TABLE1 LEFT OUTER JOIN TABLE2 ON DEPT_NO = 003420930}
The following syntax can be used at the end of a LIKE predicate:
{escape '<escape-character>'}
Example:
SELECT name FROM Identifiers WHERE Id LIKE '\\_%' {escape '\\'}
The escape syntax for limiting the number of rows returned by a query is:
{limit <limit clause>}
where the format for the limit clause is:
rows [offset row_offset]
Example:
SELECT * FROM TABLE1 WHERE F1 >100 {limit 20}
More information can be found in the JDBC Specification JSR 221, section 13.4 Escape Syntax (Direct PDF Link)