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

  • 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 359
6 Using Database Toolbox Functions
6-18
Exporting Data to New Record in Database
This example does the following:
1
Retrieves sales data from a salesVolume table.
2
Calculates the sum of sales for 1 month.
3
Stores this data in a cell array.
4
Exports this data to a yearlySales table.
You learn to use the following Database Toolbox functions:
get
fastinsert
setdbprefs
For details about these functions, see matlab\toolbox\database\dbdemos
\dbinsertdemo.m.
1
Connect to the data source, dbtoolboxdemo, if needed:
conn = database('dbtoolboxdemo', '', '');
Alternatively, you can use the native ODBC interface for an ODBC connection. For
details, see database.
2
Use setdbprefs to set the format for retrieved data to numeric:
setdbprefs('DataReturnFormat','numeric')
3
Import ten rows of data the March column of data from the salesVolume table.
curs = exec(conn, 'select March from salesVolume');
curs = fetch(curs);
4
Assign the data to the MATLAB workspace variable AA:
AA = curs.Data
AA =
981
1414
890
1800
2600
Vue de la page 359
1 2 ... 355 356 357 358 359 360 361 362 363 364 365 ... 683 684

Commentaires sur ces manuels

Pas de commentaire