❗Responses
If you followed all of the chapters until now, in particular if you used the config file when starting ws4sql and submitted the request, you'll get the following response. Just as the request was "complete", this response illustrates all the necessary concepts.
Everything ran successfully, but for node #4, whose failure was managed; and the transaction was committed.
If successful, the returned HTTP code is 200, and the response body consists of an array of results, one for each query in the request.
If unsuccessful, the HTTP code would have been 400 or 500, and the response body will report the error, as discussed in the next chapter.
Let's go through the nodes in results
, one by one:
Result of a Query
Nodes 1 and 2
These nodes represent the result of the execution of a query
. The corresponding requests were:
A query
is a statement that returns results in form of a result set.
In the results, you can see a node named resultSet
, an array of objects. Each object represents a record returned by the query, and is a map (key-value) of all the fields in the record. The key is the field name, as returned by the database, and the value is the (typed) field value.
Notice that we selected for *
, so the database auto-assigned the keys to the name of the fields.
Result of a (non-Query) Statement
Node 3
This is the result of a statement
. The request was:
A statement
node is a SQL command that does not return a result set; it usually alters the database, and it returns the number of rows changed by it.
Notice that DDL statements, like CREATE
or ALTER
, return 0 as the number of changed rows.
The rowsUpdated
node contains this piece of information.
(Non-blocking) Error
Node 4
The request was:
This statement failed, but it was marked as noFail
. So, it didn't rollback the whole transaction, but reported a failure for just this request, and in the end the transaction was committed.
See further discussion in the relevant section.
Result of a Batch Statement
The request was:
The statement was provided via a Stored Query, but this is just transparent, doesn't change the response in any way.
But this statement had two sets of values passed to it, a batch. We can see that the result contains this:
So, the server returns a "rows updated" count for every item of the batch, aka for each iteration of the statement.
Last updated