User`s guide

7 Functions — Alphabetical List
7-116
sqlquery = 'select * from productTable';
curs = exec(conn,sqlquery,10)
curs =
Attributes: []
Data: 0
DatabaseObject: [1x1 database]
RowLimit: 0
SQLQuery: 'select * from productTable'
Message: []
Type: 'Database Cursor Object'
ResultSet: [1x1 sun.jdbc.odbc.JdbcOdbcResultSet]
Cursor: [1x1 com.mathworks.toolbox.database.sqlExec]
Statement: [1x1 sun.jdbc.odbc.JdbcOdbcStatement]
Fetch: 0
After finishing with the cursor object, close it.
close(curs)
Use a Variable in a Query
Using the dbtoolboxdemo data source, select data from the productTable table that
you access using the database connection conn, where productdesc is a variable. In
this example, you are prompted to specify the product description. Your input is assigned
to the variable productdesc.
productdesc = input('Enter your product description: ', 's')
The following prompt appears.
Enter your product description:
Type the following into the Command Window.
Train Set
To perform the query using your input, run the following code.
sqlquery = ['select * from productTable'...
'where productDescription = ' '''' productdesc ''''];
curs = exec(conn,sqlquery);
curs = fetch(curs);