Appearance
CommitTransaction
提交数据库事务
结束事务,并提交事务开始后的所有数据库操作。
业务属性
属性 | 含义 | 说明 | 输入值 | 示例 |
---|---|---|---|---|
enable | 是否启用该控件,未启用时不编译 | 是否编译 | 选择值 | 启用 |
text | 与控件关联的文本 | 设计页控件显示 | 常量 | CommitTrans |
使用示例
假如我们有一表test_table
,该表的数据如下:
id | status |
---|---|
100 | 1 |
200 | 1 |
增加StartTransaction控件,开始事务:

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

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

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

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

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