Executes the parameterised prepared SQL statement represented by Cursor, previously prepared by session_sql_prepare/4 or session_sql_prepare_query/5. The predicate executes a number of tuples from TupleList, taking the tuples in order from the start of the list, leaving the unprocessed tuples in RestTupleList. The number of tuple processed is unified with Executed. Any results produced when executing a tuple is discarded when the next tuple is processed.
The number of tuples processed per call is determined by the library. This freedom allows the predicate to process a multiple number of tuples in the most efficient way for the DBMS.
Each 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.
MySQL specific note: MySQL does not support the execution of multiple tuples in one go, so for MySQL, this predicate is essentially equivalent to executing cursor_next_execute/1 multiple times.
transfer_(Session, Amount, FromAccount, ToAccount) :- SQL = "update accounts set balance = balance + ? where id = ?", Deduct is - Amount, session_sql_prepare(Session,incbal(1.0,12),SQL,2,Update), Updates = [incbal(Deduct,FromAccount),incbal(Amount,ToAccount)], % execute both updates with one call to cursor_N_execute/4 cursor_N_execute(Update,2,Updates,).