Download What Is the Database Toolbox?
Transcript
set Insert data, cell array G, into the column names ColNames of the Growth table: insert(conn1, 'Growth', ColNames, G) The data is inserted and committed. Example 3 – Set autocommit flag to off and commit data This example shows a database insert when the autocommit flag is off and the data is then committed. First set the autocommit flag to off for database connection connA: set(connA, 'autocommit', 'off'); Insert data, cell array A, into the column names ColNames of the Avg_Freight_Cost table: insert(connA, 'Avg_Freight_Cost', ColNames, A) Commit the data: cursorset = exec(connA,'commit') Example 4 – Set autocommit flag to off and roll back data This example shows a database update when the autocommit flag is off and the data is then rolled back. First set the autocommit flag to off for database connection connB: set(connB, 'autocommit', 'off'); Update the data in the column names specified by ColNames of the Avg_Freight_Weight table for the record selected by whereClause using data contained in cell array B: update(connB, 'Avg_Freight_Weight', ColNames, B, whereClause) The data was written but not committed. Roll back the data: cursorset = exec(connB,'rollback') The data in the table is now the same as it was before update was run. See Also database, exec, fetch, get, insert, update 4-29