User`s guide

7 Functions — Alphabetical List
7-136
close(curs)
close(conn)
Insert Boolean Data
Connect to the data source dbtoolboxdemo. This data source identifies a Microsoft
Access database. This database contains the table invoice with these columns:
InvoiceNumber
InvoiceDate
productNumber
Paid
Receipt
conn = database('dbtoolboxdemo','admin','admin');
Alternatively, you can use the native ODBC interface for an ODBC connection. For
details, see database.
Display the data in the invoice table before insertion.
curs = exec(conn,'select * from invoice');
curs = fetch(curs);
curs.Data
ans =
...
[41011] '2011-12-12 00:00...' [ 8] [1] [1920474x1 int8]
[61178] '2012-01-15 00:00...' [ 9] [0] [2378330x1 int8]
[62145] '2012-01-23 00:00...' [10] [1] [ 492314x1 int8]
Create data as a structure containing the invoice number 2101 and the Boolean data
1 to signify paid. Boolean data is represented as the MATLAB type logical. Here,
assume that the receipt image is missing.
data.InvoiceNumber{1} = 2101;
data.InvoiceDate{1} = datestr(now,'yyyy-mm-dd HH:MM:SS');
data.productNumber{1} = 11;
data.Paid{1} = logical(1);
Insert the paid invoice data into the invoice table with column names colnames.