MATLAB DATABASE TOOLBOX RELEASE NOTES Podręcznik Użytkownika Strona 674

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 684
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 673
7 Functions — Alphabetical List
7-244
Update the column Quantity in the inventoryTable for the products with product
numbers equal to 5 and 8. Create a cell array whereclause that contains two WHERE
clauses for both products.
tablename = 'inventoryTable';
whereclause = {'where productNumber = 5';'where productNumber = 8'};
update(conn,tablename,colnames,data,whereclause)
Fetch the data again and view the updated contents in inventoryTable.
curs = exec(conn,'select * from inventoryTable');
curs = fetch(curs);
curs.Data
ans =
...
[ 5] [10000] [ 3] '2012-09-14 15:00...'
[ 6] [ 4540] [ 8] '2013-12-25 19:45...'
[ 7] [ 6034] [ 16] '2014-08-06 08:38...'
[ 8] [ 5000] [ 5] '2011-06-18 11:45...'
...
The product with the product number equal to 5 has an updated quantity of 10000 units.
The product with the product number equal to 8 has an updated quantity of 5000 units.
After finishing with the cursor object, close it.
close(curs)
Close the database connection.
close(conn)
Update Multiple Columns 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
Przeglądanie stron 673
1 2 ... 669 670 671 672 673 674 675 676 677 678 679 ... 683 684

Komentarze do niniejszej Instrukcji

Brak uwag