User`s guide
7 Functions — Alphabetical List
7-140
Examples
Import All Data Using the Native ODBC Interface and Cursor Object
Create a connection conn using the native ODBC interface and the dbtoolboxdemo
data source.
conn = database.ODBCConnection('dbtoolboxdemo','admin','admin')
conn =
ODBCConnection with properties:
Instance: 'dbtoolboxdemo'
UserName: 'admin'
Message: []
Handle: [1x1 database.internal.ODBCConnectHandle]
TimeOut: 0
AutoCommit: 0
Type: 'ODBCConnection Object'
conn has an empty Message property, which means a successful connection.
Working with the dbtoolboxdemo data source, use fetch to import all data into the
database.ODBCCursor object, curs, and store the data in a cell array contained in the
cursor object property curs.Data.
curs = exec(conn,'select productDescription from productTable');
curs = fetch(curs)
curs =
ODBCCursor with properties:
Data: {10x1 cell}
RowLimit: 0
SQLQuery: 'select productDescription from productTable'
Message: []
Type: 'ODBCCursor Object'
Statement: [1x1 database.internal.ODBCStatementHandle]
With the native ODBC interface, curs returns an ODBCCursor Object instead of a
Database Cursor Object.
View the contents of the Data element in the cursor object.
curs.Data