User`s guide
6 Using Database Toolbox Functions
6-50
fetch(curs)
curs2 = fetch(curs)
• The next time fetch is run, records are imported starting with the row following the
specified number of rows in rowlimit. If you specify a row limit of 0, all the rows of
data are fetched.
• Fetching large amounts of data can result in memory or speed issues. Use rowlimit
to limit how much data you retrieve at once.
• If 'FetchInBatches' is set to 'yes' in the preferences using setdbprefs, fetch
incrementally fetches the number of rows specified in the 'FetchBatchSize' setting
until all the rows returned by the query are fetched, or until the limited number of
rows are fetched, if rowlimit is specified. Use this method when fetching many rows
from the database.
Caution: Leaving cursor and connection objects open or overwriting open objects can
result in unexpected behavior. Once you finish working with these objects, you must close
them using close.
Using fetch with Cursor and Database Connection Objects
fetch behaves differently when you specify a cursor object or a database connection
object as the first argument. This table explains these differences.
Difference Cursor Object Database Connection Object
Syntax For details, see fetch. For details, see fetch.
Driver This syntax works with
native ODBC, JDBC, and
the JDBC/ODBC bridge.
This syntax works with
JDBC and the JDBC/ODBC
bridge.
Output Returns a cursor object with
properties.
Returns a MATLAB variable
with the output data.
Initialization You must run exec to
create the cursor object.
You can run fetch
immediately.
Row limit You can limit the number
of total rows returned by
using the row limit input
argument.
fetch returns all rows in
the MATLAB variable.