MATLAB DATABASE TOOLBOX RELEASE NOTES Guia do Utilizador Página 565

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 684
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 564
fastinsert
7-135
The last row contains the inserted data.
Close the cursor and database connection.
close(curs)
close(conn)
Insert and Commit Data
Connect to the data source dbtoolboxdemo. This data source identifies a Microsoft
Access database. This database contains the table inventoryTable with these columns:
productNumber
Quantity
Price
inventoryDate
conn = database('dbtoolboxdemo','admin','admin');
Alternatively, you can use the native ODBC interface for an ODBC connection. For
details, see database.
Set the AutoCommit flag to off.
set(conn,'AutoCommit','off')
Insert the cell array data into the inventoryTable with column names colnames.
data = {157,358,740.00,datestr(now,'yyyy-mm-dd HH:MM:SS')};
colnames = {'productNumber','Quantity','Price','inventoryDate'};
tablename = 'inventoryTable';
fastinsert(conn,tablename,colnames,data)
Commit the inserted data.
commit(conn)
Alternatively, commit the data using an SQL commit statement with the exec function.
curs = exec(conn,'commit');
Close the cursor and database connection.
Vista de página 564
1 2 ... 560 561 562 563 564 565 566 567 568 569 570 ... 683 684

Comentários a estes Manuais

Sem comentários