User`s guide

setdbprefs
7-227
conn = database('MySQL','username','pwd');
Specify NaN for the NullNumberWrite format.
setdbprefs('NullNumberWrite','NaN')
Numbers represented as NaN in the MATLAB workspace are exported to databases as
NULL.
Select data in the table inventoryTable.
curs = exec(conn,'select * from inventoryTable');
curs = fetch(curs);
curs.Data
ans =
...
[14] [2000] [19.1000] '2014-10-22 10:52...'
[15] [1200] [20.3000] '2014-10-22 10:52...'
[16] [1400] [34.3000] '1999-12-31 00:00...'
Specify data ex_data to export into inventoryTable. ex_data contains a NaN. For the
inventory date, specify the date as the current moment.
ex_data = {24,NaN,30.00,datestr(now,'yyyy-mm-dd HH:MM:SS')};
Insert ex_data into the database using fastinsert with column names:
productNumber, Quantity, Price, and inventoryDate.
colnames = {'productNumber','Quantity','Price','inventoryDate'};
fastinsert(conn,'inventoryTable',colnames,ex_data)
Select data in the table inventoryTable to see the last row with NaN data.
curs = exec(conn,'select * from inventoryTable');
curs = fetch(curs);
curs.Data
ans =
...
[15] [1200] [20.3000] '2014-10-22 10:52...'
[16] [1400] [34.3000] '1999-12-31 00:00...'