[ library(dbi) | Reference Manual | Alphabetic Index ]

cursor_next_execute(++Cursor, +Tuple)

Executes the parametrised prepared SQL statement represented by Cursor.
A cursor handle
A tuple of parameter values matching the template for this cursor (structure)


Executes the parameterised prepared SQL statement represented by Cursor, previously prepared by session_sql_prepare/4 or session_sql_prepare_query/5. The parameter values for this execution is supplied by Tuple.

Tuple is a structure whose name and arity match the parameter template when Cursor was prepared, and the arguments give the values for the parameters for this execution, and must be compatible with the type specified by the template, except that an argument can be an uninstantiated variable, to denote a NULL value for the corresponding parameter.

If the SQL statement is a query, then it should be prepared as a query using session_sql_prepare_query/5, and results can be obtained from the query by the cursor_*_tuple family of predicates. A dbi_bad_template error would be raised if the query was prepared with session_sql_prepared/4, because no result tuple template was specified.

This predicate is called with default options for the cursor, i.e. it is equivalent to calling cursor_next_execute/3 with an empty Options list.


(5) type error
Cursor is not a valid cursor handle
(5) type error
Type mismatch between parameter template specification for Cursor and actual tuple data
Parameter value(s) too big for the buffer
Error from DBMS while executing SQL associated with Cursor.
ParamTemplate not specified when Cursor was created
The Cursor is not in a state to execute a query (e.g. it was cancelled)


  % note '?' in SQL in the syntax MySQL uses for placeholders. This may be
  % different in other DBMS
  transfer_(Session, Amount, FromAccount, ToAccount) :-
      SQL = "update accounts set balance = balance + ? \
                                               where id = ?",
      Deduct is - Amount,
      % incbal(1.0,12) is the parameter template

See Also

cursor_next_execute / 3, cursor_all_execute / 2, cursor_N_execute / 4, session_sql_prepare / 4, session_sql_prepare_query / 5