User`s guide
7 Functions — Alphabetical List
7-168
Select and display the data from the yearlySales table.
curs = exec(conn,'select * from yearlySales');
curs = fetch(curs);
curs.Data
ans =
Month salesTotal Revenue
--------- ---------- -------
'January' 130 1200
'Feb' 25 250
Store the column names of yearlySales in a cell array.
colnames = {'Month','salesTotal','Revenue'};
Store the data for the insert in a cell array, data. The data contains Month equal to
'March', salesTotal equal to $50, and Revenue equal to $2000.
data = {'March',50,2000};
Insert the data into yearlySales.
tablename = 'yearlySales';
insert(conn,tablename,colnames,data)
Display the data from yearlySales again.
curs = exec(conn,'select * from yearlySales');
curs = fetch(curs);
curs.Data
ans =
Month salesTotal Revenue
--------- ---------- -------
'January' 130 1200
'Feb' 25 250
'March' 50 2000
A new row appears in yearlySales with the data from data.
After finishing with the cursor object, close it.
close(curs)