User`s guide
7 Functions — Alphabetical List
7-34
cursor.fetch
Import data into MATLAB Workspace from cursor object created by exec
Alternatives
Retrieve data using Database Explorer.
Syntax
curs = fetch(curs,rowLimit)
curs = fetch(curs)
Description
curs = fetch(curs,rowLimit) imports rows of data into the object curs from the
open SQL cursor curs, up to the maximum rowLimit.
curs = fetch(curs) imports rows of data from the open SQL cursor curs into the
object curs, up to rowLimit. Use the set function to specify rowLimit.
Data is stored in a MATLAB cell array, table, dataset array, structure, or numeric
matrix. It is a best practice to assign the object returned by fetch to the variable curs
from the open SQL cursor. This practice results in only one open cursor object, which
consumes less memory than multiple open cursor objects.
The next time fetch is run, records are imported starting with the row following the
specified rowLimit. If you specify a rowLimit of 0, all the rows in the resultset are
fetched.
If 'FetchInBatches' is set to 'yes' in the preferences using setdbprefs,
cursor.fetch incrementally fetches the number of rows specified in the
'FetchBatchSize' setting until all the rows returned by the query are fetched, or until
rowLimit number of rows are fetched, if rowLimit is specified. Use this method when
fetching a large number of rows from the database.