Execute SQL (POST)
/mobile/platform/database/sql
Executes the SQL statement that you pass in the Oracle-Mobile-SQL
header. You can call this operation only from custom code.
You can use this operation for any type of SQL statement, such as INSERT, UPDATE, MERGE, DELETE, or SELECT.
If the SQL statement takes parameters, such as SELECT * FROM MOVIES where TITLE = :title and YEAR = :year
, then put the parameters and their values in the request body, for example {"title" : "The Imitation Game", "year" : "2014"}
.
You can't use this operation to implicitly create a table. It must already exist. When you use this operation to insert a row into a table, the request body can't have any columns that aren't in the table already.
For security reasons, you can call this operation only from custom API implementations by using the custom code SDK. You can't make direct requests from client applications. This API is included in this reference merely to describe the request and response bodies for the custom code SDK calls.
Request
- application/json
-
Oracle-Mobile-SQL: string
The URL-encoded SQL statement to execute. For example:
SELECT SUM("totalGross") "salesByGenre", "genre" FROM "Movies" GROUP BY "genre"
array
0
true
-
Array of:
object parmData
Parameter name and value. For example `{ "title" : "The Imitation Game"}`
object
{
"year":"2014",
"title":"The Imitation Game"
}
Response
- application/json
200 Response
The structure of the response JSON object depends on the SQL verb and whether the table has a primary key.
SELECT example:
{"items":[{ "title" : "The Imitation Game"}] }
INSERT, DELETE, UPDATE, MERGE example when the row has a primary key:{ "rowCount" : 2 }
INSERT, DELETE, UPDATE, MERGE example when the row key is the id
column:{"items":[{"id":42},{"id":43}]}
object
object
-
rowCount:
integer
Number of rows added, updated, or deleted
object
-
items:
array idRowData
Minimum Number of Items:
0
Unique Items Required:true
object
-
items(optional):
array tableData
Minimum Number of Items:
1
Unique Items Required:true
array
0
true
array
1
true
-
Array of:
object rowData
Additional Properties Allowed: additionalPropertiesColumn names and values. For example `{ "title" : "The Imitation Game"}`. String values can't exceed 4000 characters. Binary types aren't supported.
object
400 Response
The request failed. Typical reasons are:
- The number of request bodyparameters doesn't match the number of bind parameters in the SQL statement
- Unique constraint violation
- Invalid SQL
- Invalid table or column name
- The SQL verb is not valid for this operation
object
Error
-
detail:
string
Message that provides the error details.
-
o:ecid:
string
Execution context ID, which is a unique identifier to correlate events or requests that are associated with the same transaction across several components.
-
o:errorCode:
string
The service's error code.
-
o:errorDetails(optional):
array o:errorDetails
Minimum Number of Items:
0
Included when the error is caused by multiple issues. -
o:errorPath:
string
The relative point in the API path where the error occurred.
-
status:
integer
HTTP status code. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more details.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
array
0
-
Array of:
object Error Detail
Title:
Error Detail
object
Error Detail
-
instance:
string
URI to the link that provides more detailed information about the error.
-
o:errorCode:
string
The service's error code.
-
o:errorPath:
string
The relative point in the API path where the error occurred.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.