User`s guide
Exporting Data to New Record in Database
6-19
2800
800
1500
1000
821
5
Calculate the sum of the March sales and assign the result to the variable sumA:
sumA = sum(AA(:))
sumA =
14606
6
Assign the month and sum of sales to a cell array to export to a database. Put the
month in the first cell of exdata:
exdata(1,1) = {'March'}
exdata =
'March'
Put the sum in the second cell of exdata:
exdata(1,2) = {sumA}
exdata =
'March' [14606]
7
Define the names of the columns to which to export data. In this example, the
column names are Month and salesTotal, from the yearlySales table in the
dbtoolboxdemo database. Assign the cell array containing the column names to the
variable colnames:
colnames = {'Month','salesTotal'};
8
Use the get function to determine the current status of the AutoCommit database
flag. This status determines whether the exported data is automatically committed
to the database. If the flag is off, you can undo an update; if it is on, data is
automatically committed to the database.
get(conn, 'AutoCommit')
ans =
on
The AutoCommit flag is set to on, so the exported data is automatically committed to
the database.
9
Use the fastinsert function to export the data into the yearlySales table. Pass
the following arguments to this function: