Skip to Main Content Skip to Search
Product Documentation

datainsert - Export MATLAB data into database table

Syntax

datainsert(connect,tablename,fieldnames,data)

Description

datainsert(connect,tablename,fieldnames,data) inserts data from the MATLAB workspace into a database table.

Tips

You can also use the fastinsert function to export MATLAB data into a database table. The fastinsert function allows more flexibility in terms of the date and time string format of input data, but it is slower than datainsert.

Input Arguments

connect

Database connection object.

tablename

Database table.

fieldnames

String array of database column names.

data

MATLAB cell array or numeric matrix.

If data is a cell array containing MATLAB dates, times or timestamps, the dates must be date strings of the form yyyy-mm-dd, times must be time strings of the form HH:MM:SS.FFF, and timestamps must be strings of the form yyyy-mm-dd HH:MM:SS.FFF. null entries must be empty strings and any NaNs in the cell array must be converted to empty strings before calling datainsert.

MATLAB date numbers and NaNs are supported for insert when data is a numeric array. Date numbers inserted into database date and time columns convert to java.sql.Date.

Examples

Export MATLAB cell array data into the field names col1, col2, and col2 in the 'inserttable' database table:

datainsert(connect,'inserttable',{'col1','col2','col2'},...
   {33.5 8.77 '2010-07-04'}) 
 

Export data from a numeric matrix into a database table:

datainsert(connect,'inserttable',{'col1','col2','col2'},...
   [33.5 8.77 734323]) 

See Also

fastinsert | insert | update

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS