set

(Not recommended) Set properties for database cursor

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

Syntax

set(object,'property',value)
set(object)

Description

set(object,'property',value) sets the value of property to value for the specified cursor.

set(object) displays all properties for object.

cursor Objects

Valid values for the property and value arguments for a cursor object are as follows.

PropertyValueDescription

'RowLimit'

positive integer

Set the RowLimit for fetch. Specify this property instead of passing RowLimit as an argument to the fetch function. When you define RowLimit for fetch by using set, then fetch behaves differently depending on what type of database you are using.

Examples

Example 1 — Set RowLimit for cursor Object

Establish a JDBC connection to a data source. Run fetch to retrieve data from the table EMP, and then set the row limit to 5.

conn = database('orcl','scott','tiger',...
	'oracle.jdbc.driver.OracleDriver',...
	'jdbc:oracle:thin:@144.212.123.24:1822:');
curs = exec(conn,'SELECT * FROM EMP');
set(curs,'RowLimit',5)
curs = fetch(curs)
curs =

  cursor with properties:

     Attributes: []
           Data: {5x8 cell}
 DatabaseObject: [1x1 database]
       RowLimit: 5
       SQLQuery: 'SELECT * FROM EMP'
        Message: []
           Type: 'Database Cursor Object'
      ResultSet: [1x1 oracle.jdbc.driver.OracleResultSet]
         Cursor: [1x1 com.mathworks.toolbox.database.sqlExec]
      Statement: [1x1 oracle.jdbc.driver.OracleStatement]
          Fetch: [1x1 com.mathworks.toolbox.database.fetchTheData]

The RowLimit property of curs is 5 and the Data property is 5x8 cell, indicating that fetch returned five rows of data.

In this example, RowLimit limits the maximum number of rows you can retrieve. Therefore, rerunning the fetch function returns no data.

Compatibility Considerations

expand all

Not recommended starting in R2018b

Introduced before R2006a