Skip to main content

executeQuery()

Last updated 11/09/2024

The

executeQuery()
is a function on the
Five
object that is used to execute SQL statements on the Five server, and returns the results. You can use
executeQuery()
to perform
SELECT
,
INSERT
,
UPDATE
, and
DELETE
operations on the database.

Available

Server

Function Signature
executeQuery([transaction,] query[, limit[, parameters...]]) : QueryResult;

ParameterTypeDefaultDescription
transaction
Transaction object
null
Transaction is optional and when not supplied the default session transaction is used
query
string
null
Query to be executed
limit
number
0
Maximum number of rows to return, optional except if supplying parameters
parameters
variableParameters for the query

When working in Five, by default Five will create a transaction upon saving or executing an action such as mail merge which

executeQuery()
will use, however, if a new transaction is created via
startTransaction()
, this can be passed in as the first parameter, and
executeQuery()
will use this transaction instead.

query
is a string representing an SQL statement or the data source ID of a saved query in your application.

limit
will limit how many rows are returned from the query. The default is
0
and this will result in Five returning all the result rows for the query.
limit
is normally optional, however, if supplying parameters,
limit
is required. The parameters after
limit
will be passed as arguments to the query.

If the optional

transaction
parameter is not a Five transaction,
executeQuery()
will expect the first parameter to be required which will be the query string or the query data source ID.

Return Value

Returns a

QueryResult
object.

Examples

executeQuery()