get
(To be removed) Retrieve object properties
The get
function will be removed in a future release. There is no
replacement for this functionality. To import data, use the fetch
function. For details, see Version History.
Description
Examples
Get cursor
Object Properties
Retrieve the properties of a cursor
object.
Establish an ODBC database connection to a MySQL® database with the user name username
and password
pwd
.
conn = database('MySQL','username','pwd');
Create a cursor
object.
curs = exec(conn,'SELECT * FROM inventoryTable');
Retrieve the properties of curs
and assign them as fields in the
structure v
.
v = get(curs)
v = struct with fields: Data: 0 RowLimit: 0 SQLQuery: 'SELECT * FROM inventoryTable' Message: [] Type: 'ODBCCursor Object' Statement: [1×1 database.internal.ODBCStatementHandle] Scrollable: 0 Position: []
Display the SQL query in the cursor
object.
v.SQLQuery
ans = 'SELECT * FROM inventoryTable'
Close the cursor
object and database connection.
close(curs) close(conn)
Input Arguments
object
— Database Toolbox™ object
cursor
object
Database Toolbox object, specified as a cursor
object.
property
— Property of Database Toolbox object
character vector | string scalar
Property of the Database Toolbox object, specified as a character vector or string scalar.
The following table shows available property names and returned values.
cursor Object
Property | Description |
---|---|
'Data' | Data in the |
'RowLimit' | Maximum number of rows. |
'SQLQuery' | SQL statement for a |
'Message' | Error message returned from |
'Type' | Object type, specifically |
'Statement' | Handle to Java® statement object. |
'Scrollable' | Logical value to identify the |
'Position' | Current position of the cursor in the data set. This property is available only for a scrollable cursor. This property behaves differently for native ODBC, JDBC, and other database drivers. This property is read-only. |
Data Types: char
| string
Output Arguments
s
— Object properties
structure
Object properties, returned as a structure that contains the object and its corresponding properties.
v
— Object property value
character vector | numeric scalar | cell array | object
Object property value, returned as a character vector, numeric scalar, cell array, or object.
Version History
Introduced before R2006aR2021a: get
function will be removed
The get
function will be removed in a future release. Use the
fetch
function to import data. Some
differences between the workflows might require updates to your code.
Use the fetch
function with the connection
object to import data from a database in one step.
In prior releases, you wrote multiple lines of code to create the cursor
object, retrieve object properties, and import data. For
example:
curs = exec(conn,sqlquery); curs = fetch(curs); s = get(curs); results = curs.Data; close(curs)
Now you can import data in one step using the fetch
function.
results = fetch(conn,sqlquery);
There is no replacement functionality for the get
function.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)