MATLAB DATABASE TOOLBOX RELEASE NOTES Guide de l'utilisateur Page 673

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 684
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 672
update
7-243
Close the database connection.
close(conn)
Update Multiple Records with Multiple Conditions
Create a database connection conn using the dbtoolboxdemo data source. This
database contains the table inventoryTable that contains these columns:
productNumber
Quantity
Price
inventoryDate
conn = database('dbtoolboxdemo','','');
Import all data from the inventoryTable using conn. Store the data in a cell
array contained in the cursor object property curs.Data. Display the data from
inventoryTable in this property.
curs = exec(conn,'select * from inventoryTable');
curs = fetch(curs);
curs.Data
ans =
...
[ 5] [9000] [ 3] '2012-09-14 15:00...'
[ 6] [4540] [ 8] '2013-12-25 19:45...'
[ 7] [6034] [ 16] '2014-08-06 08:38...'
[ 8] [8350] [ 5] '2011-06-18 11:45...'
...
Define a cell array containing the column name that you are updating called Quantity.
colnames = {'Quantity'};
Define a cell array containing the new data.
A = 10000; % new quantity for product number 5
B = 5000; % new quantity for product number 8
data = {A;B}; % cell array with the new quantities
Vue de la page 672
1 2 ... 668 669 670 671 672 673 674 675 676 677 678 ... 683 684

Commentaires sur ces manuels

Pas de commentaire