User`s guide

Call a Stored Procedure That Returns Data
6-43
Driver: []
URL: []
Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
Message: []
Handle: [1x1 com.microsoft.sqlserver.jdbc.SQLServerConnection]
TimeOut: 0
AutoCommit: 'on'
Type: 'Database Object'
database returns conn, a connection Database Object for the 'test_db' database.
Alternatively, you can use the native ODBC interface for an ODBC connection. For
details, see database.
Call the Stored Procedure
To return the result set in table format, use setdbprefs to set 'DataReturnFormat'
to 'table'.
setdbprefs('DataReturnFormat','table')
Call the stored procedure, getSupplierInfo, to return supplier information for the city
of New York using exec with conn.
sqlquery = '{call getSupplierInfo(''New York'')}';
curs = exec(conn,sqlquery)
curs =
Attributes: []
Data: 0
DatabaseObject: [1x1 database]
RowLimit: 0
SQLQuery: '{call getSupplierInfo('New York')}'
Message: []
Type: 'Database Cursor Object'
ResultSet: [1x1 com.microsoft.sqlserver.jdbc.SQLServerResultSet]
Cursor: [1x1 com.mathworks.toolbox.database.sqlExec]
Statement: [1x1 com.microsoft.sqlserver.jdbc.SQLServerStatement]
Fetch: 0
exec returns a Database Cursor Object, curs, containing the supplier information.
Retrieve Output Data from the Stored Procedure
Retrieve supplier data from curs using fetch.