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

cursor_N_tuples(++Cursor, -Retrieved, -ResultTuples, -RestResultTuples)

Retrieve result tuples from the SQL query in the difference list ResultTuples and RestResultTuples.
A cursor handle
Number of result tuples retrieved
Returned difference list (with RestResultTuples) of result tuples
Tail of returned result tuples


This is similar to cursor_all_tuples/4 except it works on difference list. It is designed to efficiently retrieve a buffer full of tuples for DBMS that support the retrieval of multiple tuples in its API. Otherwise, all the remaining tuples are retrieved one by one and the ResultTuples list constructed. Retrieved is unified with the number of retrieved result tuples. If no tuples match the query, Retrieved will be 0. Each element of the list is a single result tuple. Cursor is a cursor previously created with session_sql_query/4 or session_sql_prepare_query/5. Each tuple in ResultTuples 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 results.

MySQL specific note: MySQL does not support the retrieval of multiple tuples in one go, so for MySQL, this predicate is essentially equivalent to retrieving the results one by one.


(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.

See Also

session_sql_query / 4, session_sql_prepare_query / 5, cursor_next_tuple / 2, cursor_all_tuples / 2