Here’s how to use the commit() function.
Description:
Commit the database transaction manually.
Syntax:
db.commit()
Note:
The function commits the transaction manually, which is the same as commit() of the Connection class in Java.
Parameter:
db |
Data source connection |
Option:
@k |
After the execution is completed, the transaction won't be committed. If this option is omitted, the transaction will be committed. |
Example:
|
A |
B |
|
1 |
=file("D://files//student.txt") |
|
|
2 |
=A1.import@t() |
|
|
3 |
=connect@e("demo") |
|
Create 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() |
|
Read the error code generated by the execution of the previous sql |
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: