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

cursor_next_tuple(++Cursor, -ResultTuple)

Retrieve the next result tuple from the SQL query in ResultTuple
A cursor handle
Returned result tuple


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
             !, fail

Fail Conditions

No more results are available for the SQL query




(5) type error
Cursor is not a valid cursor handle
(5) type error
Unable to convert tuple result to ECLiPSe type
Error from DBMS while executing SQL associated with Cursor.
Error from DBMS while fetching result
The SQL associated with Cursor is not a query and so cannot return results.
Result value(s) too big for the buffer
The cursor have been cancelled.


  check_overdraft_limit(Session, Account) :-
      L = ["select count(id) from accounts \
          where     id = ",Account," and balance < overdraft"],
      Count = 0.