SQLRollbackTransaction
This feature is not supported on the Wolfram Cloud.

SQLRollbackTransaction[conn]
terminates an SQL transaction.

SQLRollbackTransaction[conn,savepoint]
returns to an SQLSavepoint.

DetailsDetails

  • To use SQLRollbackTransaction, 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.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

In[1]:=
Click for copyable input

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 package, as described in Using the Example Databases.

Open a connection:

In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input

Begin a transaction:

In[4]:=
Click for copyable input

Insert data:

In[5]:=
Click for copyable input
In[6]:=
Click for copyable input

Roll back previous inserts:

In[7]:=
Click for copyable input
In[8]:=
Click for copyable input

Commit the transaction:

In[9]:=
Click for copyable input

The table only contains data inserted after the rollback:

In[10]:=
Click for copyable input
Out[10]=

Begin another transaction:

In[11]:=
Click for copyable input

Insert data:

In[12]:=
Click for copyable input

Create a savepoint:

In[13]:=
Click for copyable input
Out[13]=

Insert more data:

In[14]:=
Click for copyable input

Roll back to the savepoint:

In[15]:=
Click for copyable input

Commit the transaction:

In[16]:=
Click for copyable input

The table only contains data inserted up to the savepoint:

In[17]:=
Click for copyable input
Out[17]=
In[18]:=
Click for copyable input
In[19]:=
Click for copyable input