Main Content

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

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

example

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.

'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.

Version History

Introduced before R2006a

collapse all

R2021a: 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.

Update 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.