Method POST
Path /res/{resName}
Query Params None
Request body One or more rows to insert. Request.xsd Content-Type: application/xml or application/json
Response body Number of rows inserted and their values. Includes any auto-generated numeric ids from columns with auto-increment/sequence defined as default value. Response.xsd Content-Type: application/xml or application/json

Description

Creates one or more rows of a flat SQL Resource or the parents or the children of a hierarchial SQL Resource. Inserts to both parent and children in the same request for the same parent are disallowed, even if non-pk parent attributes are provided.

XML Examples

A flat SQL Resource:
POST /restsql/res/Actor HTTP/1.1
Content-Type: application/xml
Accept: application/xml

<request>
   <actor actor_id="123" first_name="JULIANNE" last_name="DENCH" />
   <actor actor_id="124" first_name="SCARLETT" last_name="BENING" />
   <actor actor_id="125" first_name="ALBERT" last_name="NOLTE" />
</request>
HTTP/1.1 200 OK
Content-Type: application/xml

<writeResponse rowsAffected="3">
   <actor actor_id="123" first_name="JULIANNE" last_name="DENCH" />
   <actor actor_id="124" first_name="SCARLETT" last_name="BENING" />
   <actor actor_id="125" first_name="ALBERT" last_name="NOLTE" />
</writeResponse>

Following is the same request minus the pk values. The autogenerated values are returned in the response.

POST /restsql/res/Actor HTTP/1.1
Content-Type: application/xml
Accept: application/xml

<request>
   <actor first_name="JULIANNE" last_name="DENCH" />
   <actor first_name="SCARLETT" last_name="BENING" />
   <actor first_name="ALBERT" last_name="NOLTE" />
</request>
HTTP/1.1 200 OK
Content-Type: application/xml

<writeResponse rowsAffected="3">
   <actor actor_id="123" first_name="JULIANNE" last_name="DENCH" />
   <actor actor_id="124" first_name="SCARLETT" last_name="BENING" />
   <actor actor_id="125" first_name="ALBERT" last_name="NOLTE" />
</writeResponse>

An insert to parents of a hierarchical SQL Resource would look identical to the proceeding.

An insert to children of one parent and another parent for a one-to-many hierarchical SQL Resource (child rows are created):
POST /restsql/res/LanguageFilm HTTP/1.1
Content-Type: application/xml
Accept: application/xml

<request>
   <language language_id="1">
	   <film year="2006" title="ADAPTATION HOLES" film_id="3" />
	   <film year="2006" title="ATLANTIS CAUSE" film_id="43" />
	   <film year="2006" title="BERETS AGENT" film_id="67" />
   </language>
   <language language_id="4" name="Quechua" />
</request>
HTTP/1.1 200 OK
Content-Type: application/xml

<writeResponse rowsAffected="4">
   <language language_id="1">
	   <film year="2006" title="ADAPTATION HOLES" film_id="3" />
	   <film year="2006" title="ATLANTIS CAUSE" film_id="43" />
	   <film year="2006" title="BERETS AGENT" film_id="67" />
   </language>
   <language language_id="4" name="Quechua" />
</writeResponse>
An insert to children of one parent and another parent for a many-to-many hierarchical SQL Resource (child rows are only associated to parent):
POST /restsql/res/ActorFilm HTTP/1.1
Content-Type: application/xml
Accept: application/xml

<request>
   <actor actor_id="123">
      <film film_id="3" />
      <film film_id="43" />
      <film film_id="67" />
   </actor>
   <actor actor_id="124" first_name="BENITO" last_name="BENINGS" />
</request>
HTTP/1.1 200 OK
Content-Type: application/xml

<writeResponse rowsAffected="4">
   <actor actor_id="123">
      <film film_id="3" />
      <film film_id="43" />
      <film film_id="67" />
   </actor>
   <actor actor_id="124" first_name="BENITO" last_name="BENINGS" />
</writeResponse>

JSON Examples

A flat SQL Resource:
POST /restsql/res/Actor HTTP/1.1
Content-Type: application/json
Accept: application/json

{ "actors": [
      { "id": 123, "first_name": "JULIANNE", "surname": "DENCH" },
      { "id": 124, "first_name": "SCARLETT", "surname": "BENING" },
      { "id": 125, "first_name": "ALBERT", "surname": "NOLTE" }
   ]
}
HTTP/1.1 200 OK
Content-Type: application/json

{ "rowsAffected": 3,
   "actors": [
      { "id": 123, "first_name": "JULIANNE", "surname": "DENCH" },
      { "id": 124, "first_name": "SCARLETT", "surname": "BENING" },
      { "id": 125, "first_name": "ALBERT", "surname": "NOLTE" }
   ]
}

Following is the same request minus the pk values. The autogenerated values are returned in the response.

POST /restsql/res/Actor HTTP/1.1
Content-Type: application/json
Accept: application/json

{ "actors": [
      { "first_name": "JULIANNE", "surname": "DENCH" },
      { "first_name": "SCARLETT", "surname": "BENING" },
      { "first_name": "ALBERT", "surname": "NOLTE" }
   ]
}
HTTP/1.1 200 OK
Content-Type: application/json

{ "rowsAffected": 3,
   "actors": [
      { "id": 123, "first_name": "JULIANNE", "surname": "DENCH" },
      { "id": 124, "first_name": "SCARLETT", "surname": "BENING" },
      { "id": 125, "first_name": "ALBERT", "surname": "NOLTE" }
   ]
}

An insert to parents of a hierarchical SQL Resource would look identical to the proceeding.

An insert to children of one parent and another parent for a one-to-many hierarchical SQL Resource (child rows are created):
POST /restsql/res/LanguageFilm HTTP/1.1
Content-Type: application/json
Accept: application/json

{ "languages": [
      { "language_id": 1,
         "films": [
            { "film_id": 3, "title": "ADAPTATION HOLES", "year": 2006 },
            { "film_id": 43, "title": "ATLANTIS CAUSE", "year": 2006 },
            { "film_id": 67, "title": "BERETS AGENT", "year": 2006 }
         ]
      },
      { "language_id": 4, "langName": "Quechua" }
   ]   
}
HTTP/1.1 200 OK
Content-Type: application/json

{ "rowsAffected": 4,
   "languages": [
      { "language_id": 1,
         "films": [
            { "film_id": 3, "title": "ADAPTATION HOLES", "year": 2006 },
            { "film_id": 43, "title": "ATLANTIS CAUSE", "year": 2006 },
            { "film_id": 67, "title": "BERETS AGENT", "year": 2006 }
         ]
      },
      { "language_id": 4, "langName": "Quechua" }
   ]   
}
An insert to children of one parent and another parent for a many-to-many hierarchical SQL Resource (child rows are only associated to parent):
POST /restsql/res/ActorFilm HTTP/1.1
Content-Type: application/json
Accept: application/json

{ "actors": [
      { "actor_id": 123,
         "films": [
            { "film_id": 3 },
            { "film_id": 43 },
            { "film_id": 67 },
         ]
      },
      { "actor_id": 124, "first_name": "BENITO", last_name="BENINGS" }
   ]   
}
HTTP/1.1 200 OK
Content-Type: application/json

{ "rowsAffected": 4,
   "actors": [
      { "actor_id": 123,
         "films": [
            { "film_id": 3 },
            { "film_id": 43 },
            { "film_id": 67 },
         ]
      },
      { "actor_id": 124, "first_name": "BENITO", last_name="BENINGS" }
   ]
}