User`s guide
database.fetch
7-59
10 1
Import Two Columns of Data and View Information About the Data
Import the InvoiceNumber and Paid columns from the Invoice table in the
dbtoolboxdemo database.
conn = database('dbtoolboxdemo','','');
setdbprefs('DataReturnFormat','cellarray')
results = fetch(conn,['select InvoiceNumber, '...
'Paid from Invoice']);
View the size of the cell array into which the results were returned.
size(results)
ans =
12 2
View the results for the first row of data.
results(1,:)
ans =
[2101] [0]
View the data type of the second element in the first row of data.
class(results{1,2})
ans =
logical
• “ Retrieve Image Data Types”
More About
Tips
• You call the database.fetch function with fetch rather than database.fetch.
You implicitly call database.fetch by passing a database object, conn, to fetch.
The fetch function also works with a cursor object. See cursor.fetch.