User`s guide
exec
7-117
curs.Data
ans =
[8] [212569] [1001] [5] 'Train Set'
The select statement is created by using square brackets to concatenate the two
strings select * from productTable where productDescription = and
'productdesc'. The pairs of four quotation marks are needed to create the pair of
single quotation marks that appears in the SQL statement around productdesc. The
outer two marks delineate the next string to concatenate, and two marks are required
inside them to denote a quotation mark inside a string.
Perform the query without a variable.
sqlquery = ['select * from productTable'...
'where productDescription = ' '''Engine Kit'''];
curs = exec(conn,sqlquery);
curs = fetch(curs);
curs.Data
ans =
[7] [389123] [1007] [16] 'Engine Kit'
After finishing with the cursor object, close it.
close(curs)
Roll Back and Commit Data in a Database
Use exec to roll back and commit data after running fastinsert, insert, or update
for which the AutoCommit flag is off.
Roll back data for the database connection conn.
sqlquery = 'rollback';
exec(conn,sqlquery);
When you do not specify an output argument, MATLAB returns the results of calling
exec into cursor object ans. Assign ans to variable curs so that MATLAB does not
overwrite the cursor object. After finishing with the cursor object, close it.
curs = ans;
close(curs)