db.rollback()

Read(975) Label: rollback, database,

Description:

Roll back a database transaction.

Syntax:

db.rollback (spn)

Note:

The function rolls back the transaction to the specified savepoint. Rollback all transactions when the parameter is omitted.

Parameter:

db

Database connection

spn

Savepoint name

Example:

 

A

B

 

1

=file("D://files//student.txt")

 

 

2

=A1.import@t()

 

 

3

=connect@e("demo")

 

Establish a connection and automatically control the commit and rollback operations

4

>A3.execute@k(A2,"update STUDENTS2 set NAME=?,GENDER=?,AGE=? where ID=?",NAME,GENDER,AGE,ID)

 

The transaction is not committed.

5

=A3.error()

 

Get the error code generated from the execution of the previous SQL statement.

6

if A5==0

>A3.commit()

Commit if there is not an error.

7

else

>A3.rollback()

Roll back if there is an error.

8

>A3.close()

 

Close the connection.

Related function:

db.close()

db.error()

db.commit()

connect()