You can use the following APIs to manage the transaction.
Syntax |
Description |
---|---|
Loads all transactions. |
|
Loads the SQL of the request in the specified transaction. |
|
Rolls back a transaction. |
Loads all transactions.
Syntax: GET /api/Transaction/LoadAll
PowerScript code example:
Integer li_rc String ls_body httpclient lhc_client lhc_client = create httpclient lhc_client.setrequestheader("Content-Type", "application/json;charset=UTF-8",true) li_rc = lhc_client.sendrequest( "Get", "http://172.25.100.32:5000/api/Transaction/LoadAll") if li_rc = 1 and lhc_client.getresponsestatuscode( ) = 200 then lhc_client.getrequestbody(ls_body) end if
When successful, it returns the response status code 200 and the following response body:
[ { "duration": 0, "status": "string", "cacheName": "string", "sessionId": "string", "application": "string", "transactionId": "string", "beginTime": "2022-02-21T02:53:31.576Z", "lastVisitTime": "2022-02-21T02:53:31.576Z" } ]
Loads the SQL of the request in the specified transaction.
Syntax: GET /api/Transaction/LoadRequestSql/{transactionId}
{transactionId} indicates the transaction ID.
PowerScript code example:
Integer li_rc String ls_body httpclient lhc_client lhc_client = create httpclient lhc_client.setrequestheader("Content-Type", "application/json;charset=UTF-8",true) li_rc = lhc_client.sendrequest( "Get", "http://172.25.100.32:5000/api/Transaction/LoadRequestSql/3722165D-3C45-4F73-A4D9-E5C0597510F9-1") if li_rc = 1 and lhc_client.getresponsestatuscode( ) = 200 then lhc_client.getrequestbody(ls_body) end if
When successful, it returns the response status code 200 and the following response body:
[ { "sessionId": "string", "modelName": "string", "sqlStatement": "string", "transactionId": "string", "operationType": "string", "startTime": "2022-02-21T02:58:34.515Z", "duration": 0 } ]
Rolls back a transaction.
Syntax: POST /api/Transaction/RollbackById/{sessionId}/{transactionId}
{sessionId} indicates the session ID.
{transactionId} indicates the transaction to be rolled back.
PowerScript code example:
Integer li_rc String ls_body httpclient lhc_client lhc_client = create httpclient lhc_client.setrequestheader("Content-Type", "application/json;charset=UTF-8",true) li_rc = lhc_client.sendrequest( "Post", "http://172.25.100.32:5000/api/Transaction/RollbackById/C22E6A1D-08CD-4748-AFEA-5B4F2C19799D/699ACD3E-F406-4D15-8DE9-14A1F9397F0F-5") if li_rc = 1 and lhc_client.getresponsestatuscode( ) = 200 then lhc_client.getrequestbody(ls_body) end if
When successful, it returns the response status code 200 and the following response body:
When failed, it returns 400 (bad request), 401 (unauthorized), or 500 (server error).
{ "sessionId": "string", "sqlErrText": "string", "transactionId": "string", "errorCode": 0 }