Queries in Functions
Last updated 17/03/2026
Overview
Queries in Five do not only need to be written in the Queries view. They can also be executed directly within functions using executeQuery(). This
allows you to run SQL statements programmatically as part of application logic.
executeQuery()
is a function available on the Five
object and
returns the results. It can be used to perform common database operations including SELECT
, INSERT
, UPDATE
, and
DELETE
.
Transactions
When working in Five, a transaction is automatically created when actions are executed, such as saving records or running processes like mail merges. By default,
executeQuery()
will
use this session transaction.
If a transaction is explicitly created using startTransaction(),
it can be passed as the first parameter so that the query runs within that transaction instead.
If the optional
transaction
parameter is not supplied, the first parameter will be treated as the required query
argument.