| Database Toolbox User's Guide | Search  Help Desk |
| fetch | Examples See Also |
Import data into MATLAB cell array
Syntax
cursor = fetch(cursor, rowlimit) cursor = fetch(cursor) cursor.data
Description
cursor = fetch(cursor, rowlimit)
imports rows of data from the open SQL cursor, up to the specified rowlimit, into the structure, cursor. It is common practice to reassign the variable cursor from the open SQL cursor to the structure returned by fetch. The next time you run fetch, records are imported starting with the row following rowlimit.
cursor = fetch(cursor)
imports rows of data from the open SQL cursor, up to the rowlimit specified by set, into the structure, cursor. It is common practice to reassign the variable cursor from the open SQL cursor to the structure returned by fetch. The next time you run fetch, records are imported starting with the row following rowlimit. If no rowlimit was specified by set, fetch imports all remaining rows of data.
cursor.data
points to the element in the structure (cell array) cursor that contains the data returned by fetch. The data types are preserved (cell arrays support mixed data types). After running fetch, display the returned data by typing cursor.data.
Use get to view properties of cursor.
Examples
Example 1 - Import all rows of data
Import all of the data into the cursor structure,cursorA:
cursorA = fetch(cursorA)The data is put in a cell array pointed to by the element
cursorA.data of the cursor structure. To display data in the cell array cursorA.data, type:
cursorA.dataMATLAB returns all of the data, which in this example consists of three columns and two rows:
ans = 'Sales' [380344] [100765] 'Operations' [289034] [100896]
Example 2 - Import specified number of rows of data
Specify therowlimit argument to retrieve the first 100 rows of data:
curs1 = fetch(curs1, 100)Entering the command again returns the second 100 rows of data:
curs1 = fetch(curs1, 100)
See Also
attr, cols, columnnames, exec, get, rows, set, width