I think the main problem here is that the column names in mycolnames
pertain to the database table, not your MATLAB table mytbl
. That has its own variable names given by {'num' 'deldate' 'myname'}
, which don't match the database column names. From the fastinsert
documentation for the data
argument:
Data to insert, specified as a numeric matrix, cell array, table, dataset array, or structure that contains all data for insertion into the existing database table tablename
. If data
is a structure, then field names in the structure must match colnames
. If data
is a table or a dataset array, then the variable names in the table or dataset array must match colnames
.
To get around this, you can either modify the variable names in your table so they match your database column names:
mytbl.Properties.VariableNames = mycolnames;
fastinsert(conn, 'simSQLTable', mycolnames, mytbl);
Or you can just extract the data from your table that needs to be inserted:
fastinsert(conn, 'simSQLTable', mycolnames, mytbl.Variables);