Response Format and REST-Enabled SQL service in ORDS
Hello fellas!! 👋
Rest-Enabled SQL service in ORDS:
The REST-Enabled SQL service is a HTTPS web service that provides access to the Oracle Database SQL engine. You can POST SQL statements to the service. The service then runs the SQL statements against Oracle Database and returns the result to the client in a JSON format.
- Example:
When making a request to the REST ENABLED SQL SERVICE, you typically by default get a response as the following:
curl --location 'http://localhost:8086/ords//<schema_alias>/_/sql' \
--header 'Content-Type: application/json' \
-u "user:dummySecret" \
--data '{
"statementText": "select sysdate from dual"
}'
This is typically how the response would look like:
{
"env": {
"defaultTimeZone": "UTC"
},
"items": [
{
"statementId": 1,
"statementType": "query",
"statementPos": {
"startLine": 1,
"endLine": 1
},
"statementText": "select sysdate from dual",
"resultSet": {
"metadata": [
{
"columnName": "SYSDATE",
"jsonColumnName": "sysdate",
"columnTypeName": "DATE",
"columnClassName": "java.sql.Timestamp",
"precision": 7,
"scale": 0,
"isNullable": 1
}
],
"items": [
{
"sysdate": "2025-04-21T16:40:07Z"
}
],
"hasMore": false,
"limit": 10000,
"offset": 0,
"count": 1
},
"response": [],
"result": 0
}
]
}
You can see that there’s a lot of insights in the response, sometimes based on your requirements you would want to limit what’s in the response, well ResponseFormat is the answer!
Here are all the responseFormat fields that you can use!
Filed name
Description
responseFormat.resultSetMetaData
Set to true, if you want resultSetMetaData to be returned in the response
responseFormat.statementInformation
Set to true, if you want statementInformation to be returned in the response
responseFormat.statementText
Set to true, if you want statementText to be returned in the response.
responseFormat.binds
Set to true, if you want the "items.binds" node to be returned in the response
responseFormat.result
Set to true, if the "items.result" node is to be returned in the response
responseFormat.response
Set to true, if the response is to be returned in the response $items.response
responseFormat.numberAsString
Determines whether numeric values in resultSet.item node should be returned as strings
When making a request to the REST ENABLED SQL SERVICE, you typically by default get a response as the following:
curl --location 'http://localhost:8086/ords//<schema_alias>/_/sql' \
--header 'Content-Type: application/json' \
-u "user:dummySecret" \
--data '{
"statementText": "select sysdate from dual"
}'
This is typically how the response would look like:
{
"env": {
"defaultTimeZone": "UTC"
},
"items": [
{
"statementId": 1,
"statementType": "query",
"statementPos": {
"startLine": 1,
"endLine": 1
},
"statementText": "select sysdate from dual",
"resultSet": {
"metadata": [
{
"columnName": "SYSDATE",
"jsonColumnName": "sysdate",
"columnTypeName": "DATE",
"columnClassName": "java.sql.Timestamp",
"precision": 7,
"scale": 0,
"isNullable": 1
}
],
"items": [
{
"sysdate": "2025-04-21T16:40:07Z"
}
],
"hasMore": false,
"limit": 10000,
"offset": 0,
"count": 1
},
"response": [],
"result": 0
}
]
}
You can see that there’s a lot of insights in the response, sometimes based on your requirements you would want to limit what’s in the response, well ResponseFormat is the answer!
Here are all the responseFormat fields that you can use!
Filed name | Description |
---|---|
responseFormat.resultSetMetaData | Set to true, if you want resultSetMetaData to be returned in the response |
responseFormat.statementInformation | Set to true, if you want statementInformation to be returned in the response |
responseFormat.statementText | Set to true, if you want statementText to be returned in the response. |
responseFormat.binds | Set to true, if you want the "items.binds" node to be returned in the response |
responseFormat.result | Set to true, if the "items.result" node is to be returned in the response |
responseFormat.response | Set to true, if the response is to be returned in the response $items.response |
responseFormat.numberAsString | Determines whether numeric values in resultSet.item node should be returned as strings |
Comments
Post a Comment