This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

get

(Not recommended) Retrieve object properties

The get function is not recommended. There is no replacement for this functionality. To import data, use the fetch function. For details, see Compatibility Considerations.

Syntax

s = get(object)
v = get(object,property)

Description

example

s = get(object) returns the structure s, which contains the object and its corresponding properties.

v = get(object,property) returns the value v of property for the object.

Examples

collapse all

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

collapse all

Database Toolbox object, specified as a cursor object.

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 PropertyDescription
'Data'

Data in the cursor object data element (the query results).

'RowLimit'

Maximum number of rows returned by fetch, as specified by set.

'SQLQuery'

SQL statement for a cursor object, as specified by exec.

'Message'

Error message returned from exec or fetch.

'Type'

Object type, specifically 'Database Cursor Object'.

'Statement'

Handle to Java® statement object.

'Scrollable'

Logical value to identify the cursor object as scrollable or basic. This property is set to 1 for a scrollable cursor and 0 otherwise. This property is hidden and read-only.

'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

collapse all

Object properties, returned as a structure that contains the object and its corresponding properties.

Object property value, returned as a character vector, numeric scalar, cell array, or object.

Compatibility Considerations

expand all

Not recommended starting in R2018b

Introduced before R2006a