Appearance
RollbackTransaction
回滚数据库事务
撤销数据库的所有已完成的操作,使数据库回到事务开始前的状态。
业务属性
属性 | 含义 | 说明 | 输入限定 | 示例值 |
---|---|---|---|---|
enable | 是否启用该控件,未启用时不编译 | 是否编译 | 选择值 | 启用 |
text | 与控件关联的文本 | 设计页控件显示 | 常量 | RollbackTrans |
使用示例
假如我们有一表test_table
,该表的数据如下:
id | status |
---|---|
100 | 1 |
200 | 1 |
增加StartTransaction控件,开始事务:

增加ExecuteSQL控件,更新数据库数据:
sql:update test_table set status='2' where id = '100'

增加[RollbackTransaction](# RollbackTransaction)控件,设置执行的if条件:
body.commit==true

增加ExecuteSQL控件,重新查询数据:
sql:select * from test_table

增加Return控件,输出查询数据:
data:{ "data": "#{executeSQL_query}"}

使用curl请求接口:
$ curl http://localhost:6636/api/rollbackTransaction -d "{\"commit\":false}"
$ curl http://localhost:6636/api/rollbackTransaction -d "{\"commit\":false}"
接口返回:
json
{
"data":
{
"result":
[
{
"status": "1",
"id": "100"
},
{
"status": "1",
"id": "200"
}
]
}
}
{
"data":
{
"result":
[
{
"status": "1",
"id": "100"
},
{
"status": "1",
"id": "200"
}
]
}
}