Retrieve the next result tuple from the SQL query represented by Cursor, and unify it with ResultTuple. Cursor is a cursor previously created with session_sql_query/4 or session_sql_prepare_query/5. ResultTuple is a structure with the same name and arity as defined by the tuple template when the cursor was created. The predicate converts the result to the type specified in the template, except that NULL values are returned as variables.
If the SQL query have not yet been executed, and it contains no parameters, then the SQL query will first be executed before retrieving the result.
cursor_next_tuple/2 will fail when all the results tuples for the query have been returned. If it is then called again for the same SQL query, this cancels the cursor, and raise the cursor cancelled error.
cursor_next_tuple/2 is not resatisfiable, so to return successive tuples
on backtracking, use repeat/0 to re-execute cursor_next_tuple/2:
match_tuple(Cursor, Tuple) :-
( cursor_next_tuple(Cursor, Tuple0) ->
Tuple0 = Tuple
check_overdraft_limit(Session, Account) :- L = ["select count(id) from accounts \ where id = ",Account," and balance < overdraft"], concat_string(L,SQL), session_sql_query(Session,c(0),SQL,OverdraftCheck), cursor_next_tuple(OverdraftCheck,c(Count)), Count = 0.