User`s guide
7 Functions — Alphabetical List
7-228
[24] [ NaN] [ 30] '2014-10-22 11:19...'
Close the connection.
close(conn)
Specify Error Handling Settings
Changing the error handling database preferences affects the display of errors in
MATLAB.
Specify the store format for the ErrorHandling preference.
setdbprefs('ErrorHandling','store')
With the ErrorHandling property set to store, errors generated by running database
or exec are stored in the Message field of the returned connection or cursor object.
Establish connection conn to a MySQL database with user name username and
password pwd. This database contains the table producttable with the column
productdescription.
conn = database('MySQL','username','pwd');
Fetch data from a closed cursor.
curs = exec(conn,'select productdescription from producttable');
close(curs)
curs = fetch(curs,3)
curs =
Attributes: []
Data: 0
DatabaseObject: [1x1 database]
RowLimit: 0
SQLQuery: 'select productdescription from producttable'
Message: 'Invalid fetch cursor.'
Type: 'Database Cursor Object'
ResultSet: 0
Cursor: 0
Statement: [1x1 sun.jdbc.odbc.JdbcOdbcStatement]
Fetch: [1x1 com.mathworks.toolbox.database.fetchTheData]
The error generated by this operation appears in the Message field.