dbBind() returns the result set,
for queries issued by
and also for data manipulation statements issued by
dbBind() for a query without parameters
raises an error.
Binding too many
or not enough values,
or parameters with wrong names
or unequal length,
also raises an error.
If the placeholders in the query are named,
all parameter values must have names
(which must not be empty
and vice versa,
otherwise an error is raised.
The behavior for mixing placeholders of different types
(in particular mixing positional and named placeholders)
is not specified.
dbBind() on a result set already cleared by
also raises an error.
DBI clients execute parametrized statements as follows:
dbSendStatement()with a query or statement that contains placeholders, store the returned '>DBIResult object in a variable. Mixing placeholders (in particular, named and unnamed ones) is not recommended. It is good practice to register a call to
on.exit()right after calling
dbSendStatement()(see the last enumeration item). Until
dbBind()has been called, the returned result set object has the following behavior:
Construct a list with parameters that specify actual values for the placeholders. The list must be named or unnamed, depending on the kind of placeholders used. Named values are matched to named parameters, unnamed values are matched by position in the list of parameters. All elements in this list must have the same lengths and contain values supported by the backend; a data.frame is internally stored as such a list. The parameter list is passed to a call to
Retrieve the data or the number of affected rows from the
Repeat 2. and 3. as necessary.
Close the result set via
The elements of the
params argument do not need to be scalars,
vectors of arbitrary length
(including length 0)
For queries, calling
dbFetch() binding such parameters returns
concatenated results, equivalent to binding and fetching for each set
of values and connecting via
For data manipulation statements,
dbGetRowsAffected() returns the
total number of rows affected if binding non-scalar parameters.
dbBind() also accepts repeated calls on the same result set
for both queries
and data manipulation statements,
even if no results are fetched between calls to
At least the following data types are accepted: