Database Toolbox |
About Objects and Methods for the Database Toolbox
The Database Toolbox is an object-oriented application. The toolbox has the following objects:
Each object has its own method directory, which begins with an @ sign, in the $matlabroot\toolbox\database\database
directory. The methods for operating on a given object are the M-file functions in the object's directory.
You can use the Database Toolbox with no knowledge of or interest in its object-oriented implementation. But for those who are interested, some of its useful aspects follow:
fetch
function to create a cursor object containing query results. MATLAB returns not only the object but also the stored information about the object. Because objects are structures in MATLAB, you can easily view the elements of the returned object.
As an example, if you create a cursor object curs
using the fetch
function, MATLAB returns
curs = Attributes: [] Data: {10x1 cell} DatabaseObject: [1x1 database] RowLimit: 0 SQLQuery: 'select country from customers' Message: [] Type: 'Database Cursor Object' ResultSet: [1x1 sun.jdbc.odbc.JdbcOdbcResultSet] Cursor: [1x1 com.mathworks.toolbox.database.sqlExec] Statement: [1x1 sun.jdbc.odbc.JdbcOdbcStatement] Fetch: com.mathworks.toolbox.database.fetchTheData]
You can easily access information about the cursor object, including the results, which are in the Data
element of the cursor object. To view the contents of the element, which is a 10-by-1 cell array in this example, you type
get
function, regardless of the object. This means you have to remember only one function, get
, rather than having to remember specific functions for each object. The properties you retrieve with get
differ, depending on the object, but the function itself always has the same name and argument syntax.
Performing Driver Functions | Working with Cell Arrays in MATLAB |
© 1994-2005 The MathWorks, Inc.