Main Content


(To be removed) Set properties for database cursor

The set 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 Compatibility Considerations.




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.



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.


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',...
curs = exec(conn,'SELECT * FROM EMP');
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

Warns starting in R2021a

Introduced before R2006a