SQLSetSavepoint[conn,name]
creates a savepoint to be used as part of an SQL transaction.
Details and Options
Examples
Basic Examples
See Also
Tech Notes
Related Guides
DatabaseLink`
DatabaseLink`
SQLSetSavepoint
SQLSetSavepoint[conn,name]
creates a savepoint to be used as part of an SQL transaction.
Details and Options
- To use SQLSetSavepoint, you first need to load DatabaseLink using Needs["DatabaseLink`"].
- A group of SQL commands grouped into a transaction will only take effect permanently when the transaction is committed. The transaction can be canceled or returned to a savepoint.
Examples
Basic Examples (1)
Needs["DatabaseLink`"]If you find that the examples in this section do not work as shown, you may need to install or restore the example database with the "DatabaseLink`DatabaseExamples`" package, as described in Using the Example Databases.
conn = OpenSQLConnection["demo"]SQLCreateTable[conn, SQLTable["TEST"], {SQLColumn["X", "DataTypeName" -> "Integer"], SQLColumn["Y", "DataTypeName" -> "Float"]}];SQLBeginTransaction[conn]SQLInsert[conn, "TEST", {"X", "Y"}, {{61, 80.3}, {72, 5.5}}];savepoint = SQLSetSavepoint[conn, "my savepoint"]SQLInsert[conn, "TEST", {"X", "Y"}, {72, 5.5}];SQLRollbackTransaction[conn, savepoint]SQLCommitTransaction[conn]The table only contains data inserted up to the savepoint:
SQLSelect[conn, "TEST"]SQLDropTable[conn, "TEST"];CloseSQLConnection[conn];