fetch
(Not recommended) Import data into MATLAB workspace from database cursor
The fetch
function with the cursor
object is not recommended. Use the fetch
function with the connection
object or the select
function instead. For details, see Version History.
The scrollable cursor functionality has no replacement.
Description
imports all rows of data from an executed SQL query into the curs
= fetch(curs
)Data
property of the cursor
object. Use the cursor
object to investigate imported data and its structure.
Caution:
Leaving cursor
and connection
objects open or overwriting open objects can result in
unexpected behavior. After you finish working with these objects, you must close them
using close
.
specifies options using one or more name-value pair arguments in addition to the input
arguments in previous syntaxes. For example, curs
= fetch(___,Name,Value
)curs =
fetch(curs,'AbsolutePosition',5);
imports data using an absolute position offset
in a scrollable cursor, whereas curs = fetch(curs,'RelativePosition',10);
imports data using a relative position offset.
Examples
Input Arguments
Output Arguments
Tips
If you have a native ODBC connection that you established using
database
, then runningfetch
on thecursor
object updates the inputcursor
object itself. Depending on whether you provide an output argument, the same object gets copied over to the output. Therefore, only onecursor
object exists in memory for any of these usages:% First use curs = fetch(curs) % Second use fetch(curs) % Third use curs2 = fetch(curs)