| Database Toolbox™ | ![]() |
v = get(object)
v = get(object, 'property')
v.property
v = get(object) returns a structure that contains object and its corresponding properties, and assigns the structure to v.
v = get(object, 'property') retrieves the value of property for object and assigns the value to v.
v.property returns the value of property after you have created v by running get.
Use set(object) to view a list of writable properties for object.
Allowable objects include:
Database Connection Objects, which are created using database
Cursor Objects, which are created using exec or fetch (cursor.fetch)
Driver Objects, which are created using driver
Database Metadata Objects, which are created using dmd
Drivermanager Objects, which are created using drivermanager
Resultset Objects, which are created using resultset
Resultset Metadata Objects, which are created using rsmd
If you call these objects from applications that use Sun™ Java™, you can get more information
about object properties from the Java Web site at http://java.sun.com/j2se/1.4.2/docs/api/java/sql/
DatabaseMetaData.html.
Allowable property names and returned values for database connection objects appear in the following table.
| Property | Value |
|---|---|
| 'AutoCommit' | Status of the AutoCommit flag. It is either on or off, as specified by set |
| 'Catalog' | Name of the catalog in the data source. You may need to extract a single catalog name from 'Catalog' for functions such as columns, which accept only a single catalog. |
| 'Driver' | Driver used for a JDBC connection, as specified by database |
| 'Handle' | Identifies a JDBC connection object |
| 'Instance' | Name of the data source for an ODBC connection or the name of a database for a JDBC connection, as specified by database |
| 'Message' | Error message returned by database |
| 'ReadOnly' | 1 if the database is read-only; 0 if the database is writable |
| 'TimeOut' | Value for LoginTimeout |
| 'TransactionIsolation' | Value of current transaction isolation mode |
| 'Type' | Object type, specifically Database Object |
| 'URL' | For JDBC connections only, the JDBC URL objectjdbc:subprotocol:subname, as specified by database |
| 'UserName' | User name required to connect to a given database, as specified by database |
| 'Warnings' | Warnings returned by database |
Allowable property names and returned values for cursor objects appear in the following table.
| Property | Value |
|---|---|
| 'Attributes' | Cursor attributes. This field is always empty. Use the attr function to retrieve cursor attributes. |
| 'Data' | Data in the cursor object data element (the query results) |
| 'DatabaseObject' | |
| 'RowLimit' | Maximum number of rows returned by fetch, as specified by set |
| 'SQLQuery' | SQL statement for a cursor, as specified by exec |
| 'Message' | Error message returned from exec or fetch |
| 'Type' | Object type, specifically Database Cursor Object |
| 'ResultSet' | Resultset object identifier |
| 'Cursor' | Cursor object identifier |
| 'Statement' | Statement object identifier |
| 'Fetch' | 0 for cursor created using exec; fetchTheData for cursor created using fetch |
Allowable property names and examples of values for driver objects appear in the following table.
| Property | Example of Value |
|---|---|
| 'MajorVersion' | 1 |
| 'MinorVersion' | 1001 |
Database metadata objects have many properties. Some allowable property names and examples of their values appear in the following table.
| Property | Example of Value |
|---|---|
| 'Catalogs' | {4x1 cell} |
| 'DatabaseProductName' | 'ACCESS' |
| 'DatabaseProductVersion' | '03.50.0000' |
| 'DriverName' | 'JDBC-ODBC Bridge (odbcjt32.dll)' |
| 'MaxColumnNameLength' | 64 |
| 'MaxColumnsInOrderBy' | 10 |
| 'URL' | 'jdbc:odbc:dbtoolboxdemo' |
| 'NullsAreSortedLow' | 1 |
Allowable property names and examples of values for drivermanager objects appear in the following table.
| Property | Example of Value |
|---|---|
| 'Drivers' | {'oracle.jdbc.driver.OracleDriver@1d8e09ef' |
| 'LoginTimeout' | 0 |
| 'LogStream' | [] |
Allowable property names and examples of values for resultset objects appear in the following table.
| Property | Example of Value |
|---|---|
| 'CursorName' | {'SQL_CUR92535700x' 'SQL_CUR92535700x'} |
| 'MetaData' | {1x2 cell} |
| 'Warnings' | {[] []} |
Allowable property names and examples of values for a resultset metadata objects appear in the following table.
| Property | Example of Value |
|---|---|
| 'CatalogName' | {'' ''} |
| 'ColumnCount' | 2 |
| 'ColumnName' | {'Calc_Date' 'Avg_Cost'} |
| 'ColumnTypeName' | {'TEXT' 'LONG'} |
| 'TableName' | {'' ''} |
| 'isNullable' | {[1] [1]} |
| 'isReadOnly' | {[0] [0]} |
The empty strings for CatalogName and TableName indicate that databases do not return these values.
For command-line help on get, use the overloaded methods:
help cursor/get help database/get help dmd/get help driver/get help drivermanager/get help resultset/get help rsmd/get
Connect to the database SampleDB, and then get the name of the data source for the connection and assign it to v.
conn = database('SampleDB', '', '');
v = get(conn, 'Instance')
Check the status of the AutoCommit flag for the database connection conn.
get(conn, 'AutoCommit') ans = on
Display data in the cursor object curs by running:
get(curs, 'Data')
or:
curs.Data
ans =
'Germany'
'Mexico'
'France'
'Canada'
View the properties of the database metadata object for connection conn; due to space constraints, only a portion of the returned data appears here.
dbmeta = dmd(conn);
v = get(dbmeta)
v =
AllProceduresAreCallable: 1
AllTablesAreSelectable: 1
DataDefinitionCausesTransaction: 1
DataDefinitionIgnoredInTransact: 0
DoesMaxRowSizeIncludeBlobs: 0
Catalogs: {4x1 cell}
NullPlusNonNullIsNull: 0
NullsAreSortedAtEnd: 0
NullsAreSortedAtStart: 0
NullsAreSortedHigh: 0
NullsAreSortedLow: 1
UsesLocalFilePerTable: 0
UsesLocalFiles: 1
To view names of the catalogs in the database, run:
v.Catalogs
ans =
'D:\matlab\toolbox\database\dbdemos\db1'
'D:\matlab\toolbox\database\dbdemos\origtutorial'
'D:\matlab\toolbox\database\dbdemos\tutorial'
'D:\matlab\toolbox\database\dbdemos\tutorial1'
columns, cursor.fetch, database, dmd, driver, drivermanager, exec, getdatasources, resultset, rows, rsmd, set
![]() | fetchmulti | getdatasources | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |