User`s guide

Delete Data from Databases
6-17
...
[10] [ 723] [ 24] '2012-03-14 13:13...'
[11] [ 567] [ 0] '2012-09-11 00:30...'
[12] [1278] [ 0] '2010-10-29 18:17...'
The record with product number 13 is missing.
Delete a Record Using a MATLAB Variable
Define a MATLAB variable productID by setting it to the product number 12.
productID = 12;
Delete the data using the MATLAB variable productID. Build an SQL statement string
that combines the SQL for the delete operation with the MATLAB variable. Since the
variable is numeric and the SQL statement is a string, convert the number to a string.
Use the num2str function for the conversion. Concatenate the delete SQL statement and
the numeric conversion using the square brackets.
curs = exec(conn,['delete * from inventoryTable where '...
'productNumber = ' num2str(productID)]);
Display the last rows in the table inventoryTable after the deletion.
curs = exec(conn,'select * from inventoryTable');
curs = fetch(curs);
curs.Data
ans =
...
[ 9] [2339] [ 13] '2011-02-09 12:50...'
[10] [ 723] [ 24] '2012-03-14 13:13...'
[11] [ 567] [ 0] '2012-09-11 00:30...'
The record with product number 12 is missing.
Close the Cursor and Database Connection
close(curs)
close(conn)
See Also
exec | fetch | num2str