Add or Update Rows
/mobile/platform/database/objects/{table}
Adds or updates one or more rows. Whether MCS performs an add or update depends on whether the table uses id
or primary key fields to uniquely identify rows.
id
field: If you include anid
property in the request body, then MCS performs an update. Otherwise it adds the row.- Primary key fields: If the table uses primary key fields, then MCS performs an update if a row exists with matching primary key values.Otherwise, it adds the row.
If the Database_CreateTablesPolicy
environment policy is allow
, then the following occur:
- If the table doesn't exist, then it's created.
- If a column doesn't exist, then the table is altered to include it.
- If the value is larger than the column size, then the column is resized. String values can't exceed 4000 characters.
Request
- application/json
-
table: string
The name of the database table.
-
Oracle-Mobile-Extra-Fields(optional): string
For an implicit table creation, optionally provide a comma-separated list that specifies which predefined columns to include in the table from amongst
id
,createdBy
,createdOn
,modifiedBy
, andmodifiedOn
. For example,createdOn,createdBy
.To not include any predefined columns, specify
none
. To include all the predefined columns, do not include the header in the request. Note that theid
column is added to the table automatically if both theOracle-Mobile-Primary-Keys
andOracle-Mobile-Extra-Fields
are absent.When you use
/mobile/platform/database/objects/{table}
endpoint operations to add or modify a row in a table that has predefined columns, the predefined columns are updated automatically. The user doesn't need to provide values for these columns. -
Oracle-Mobile-Primary-Keys(optional): string
For an implicit table creation, provide a URL-encoded, comma-separated list specifying which attributes of the JSON object in the request body constitute the table's primary key. For example,
lastName,firstName
. Note that when you retrieve, update, or delete rows in a table you must specify the keys in the same order that you specified when you first created or re-created the table. However, when you call eitherGET /mobile/system/databaseManagement/tables
orGET /mobile/system/databaseManagement/tables/{table}
, theprimaryKeys
property lists the columns in alphabetical order, and not in the order that you used when you created or re-created the table. Therefore, you must make a note of the order when you create or re-create a table.If you don't specify a primary key and you don't specify additional fields, then MCS adds an
id
column to the table, and generates the column's values automatically.
object
Added or Updated Items
-
object Columns
Title:
Columns
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. -
array Table Data
Title:
Table Data
Minimum Number of Items:1
Unique Items Required:true
object
Columns
array
Table Data
1
true
-
Array of:
object Columns
Title:
Columns
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.
[
{
"id":1,
"title":"Fear",
"year":1954
},
{
"id":2,
"title":"Annie",
"year":1982
}
]
Response
- application/json
200 Response
The structure of the response JSON object depends on if the table has a primary key:
Example when the table has a primary key:
{ "rowCount" : 2 }
Example when the row key is the id
column:{"items":[{"id":42},{"id":43}]}
object
Add, Update, or Delete Response
-
object Row Count
Title:
Row Count
-
object Added, Updated, or Deleted Items
Title:
Added, Updated, or Deleted Items
IDs for the rows that were added, updated, or deleted.
object
Row Count
-
rowCount:
integer
Number of rows added, updated, or deleted
object
Added, Updated, or Deleted Items
-
items:
array Row Data
Title:
Row Data
Minimum Number of Items:0
Unique Items Required:true
array
Row Data
0
true
-
Array of:
object ID
Title:
ID
object
ID
-
id(optional):
integer
Value of the `id` column.