Import data from multiple resultsets


curs = fetchmulti(curs)


curs = fetchmulti(curs) imports data from the open SQL cursor object curs into the object curs, where the open SQL cursor object contains multiple resultsets.

Multiple resultsets are retrieved via exec with a sqlquery statement that runs a stored procedure consisting of two select statements.

curs.Data contains data from each resultset associated with curs.Statement. curs.Data is a cell array consisting of cell arrays, structures, or numeric matrices as specified in setdbprefs; the data type is the same for all resultsets.


Use exec to run a stored procedure that includes multiple select statements and fetchmulti to retrieve the resulting multiple resultsets.

conn = database(...)
curs = exec(conn,'{call sp_1}');
curs = fetchmulti(curs)
Attributes: []
              Data: {{10x1 cell} {12x4 cell}}
    DatabaseObject: [1x1 database]
          RowLimit: 0
          SQLQuery: '{call sp_1}'
           Message: []
              Type: 'Database Cursor Object'
         ResultSet: [1x1 sun.jdbc.odbc.JdbcOdbcResultSet]
										[1x1 sun.jdbc.odbc.JdbcOdbcResultSet]
            Cursor: ...
			  [1x1 com.mathworks.toolbox.database.sqlExec]
         Statement: [1x1 sun.jdbc.odbc.JdbcOdbcStatement]
								 		[1x1 sun.jdbc.odbc.JdbcOdbcStatement]
             Fetch: ...
			  [1x1 com.mathworks.toolbox.database.fetchTheData]

Related Examples

See Also

| | |

Was this topic helpful?