MATLAB: How to perform multiple insertions to a database using one call to FASTINSERT

Database Toolboxsun.jdbc.odbc.jdbcodbcpreparedstatement

The existing FASTINSERT function processes one insertion at a time while inserting to a database. However, I would like to pass a cell containing multiple data sets so my 'exdata' would have for example the following dimensions:
exdata =
[cell 1x4] [cell 1x4] [cell 1x4] [double 1x4]
However I get an error message passing 'exdata' to FASTINSERT.

Best Answer

FASTINSERT processes each record separately, that is why you will receive an error message when passing:
exdata =
[cell 1x4] [cell 1x4] [cell 1x4] [double 1x4]
However it is possible to pass multiple records in one call to FASTINSERT if your data is converted to the following format:
exdata =
[cell 1x1] [cell 1x1] [cell 1x1] [double 1x1]
[cell 1x1] [cell 1x1] [cell 1x1] [double 1x1]
[cell 1x1] [cell 1x1] [cell 1x1] [double 1x1]
[cell 1x1] [cell 1x1] [cell 1x1] [double 1x1]
The reshaping of the cell can be done by a simple FOR loop or the CELLFUN command:
exdata = cell(dima,4);
for i = 1:dima
exdata{i,1} = mydata1(i);
exdata{i,2} = dates(i);
exdata{i,3} = ID(i);
exdata{i,4} = mydata2(i);
end