OCI SODA Functions
The following table lists the OCI SODA functions that are described in this chapter.
Table 36-1 OCI SODA Functions
Function | Purpose |
---|---|
OCISodaBulkInsert() |
Inserts a document array into a collection. |
OCISodaBulkInsertAndGet() |
Inserts a document array into a collection and gets the result document array back. |
OCISodaBulkInsertAndGetWithOpts
() |
Inserts several SODA documents with options. |
OCISodaBulkInsertAndGetWithCtnt() |
Inserts a document array into a collection and gets the result document array back. The input documents are represented as an array of content strings and an array of keys. |
OCISodaBulkInsertWithCtnt() |
Inserts an array of documents into a collection. The documents are represented as an array of content strings and an array of keys. |
OCISodaCollCreate() |
Creates a new document collection with default metadata settings. |
OCISodaCollCreateWithMetadata() |
Creates a new document collection with metadata. |
OCISodaCollDrop() |
Drops a collection from the database. |
OCISodaCollGetNext() |
Gets the next collection from the collection cursor. |
OCISodaCollList() |
Lists the collections in the schema associated with the supplied service context handle parameter. |
OCISodaCollOpen() |
Opens the collection. |
OCISodaDataGuideGet() |
Gets JSON data guide information. |
OCISodaDataGuideGetWithOpts ()
|
Get data guide with options. |
OCISodaDocCount() |
Counts the number of documents from a collection. |
OCISodaDocCountWithFilter() |
Counts the number of documents in a collection based on the query-by-example filter document. |
OCISodaDocCreate() |
Creates a document. |
OCISodaDocCreateWithKey() |
Creates a document with document key and content. |
OCISodaDocCreateWithKeyAndMType() |
Creates a document with document key, content, and media type. |
OCISodaDocGetNext() |
Gets the next document in the collection. |
OCISodaFind() |
Find documents in a collection. |
OCISodaFindOne() |
Finds a single document in a collection. |
OCISodaFindOneWithKey() |
Finds a single document in a collection given a key. |
OCISodaIndexCreate() |
Creates an index with an index specification. |
OCISodaIndexDrop() |
Drops an index. |
OCISodaInsert() |
Inserts a document into a collection. |
OCISodaInsertAndGet() |
Inserts a document into a collection and returns a result document. |
OCISodaInsertAndGetWithOpts
() |
Inserts a SODA document with options. |
OCISodaInsertAndGetWithCtnt() |
Inserts a document into a collection and returns a result document. The input document is represented as a content string and a key |
OCISodaInsertWithCtnt() |
Inserts a document into a collection. The document is represented as a content string and a key |
OCISodaRemove() |
Removes matching documents from a collection. |
OCISodaRemoveOneWithKey() |
Removes a document from a collection given a key. |
OCISodaReplOne() |
Replaces a document in a collection. |
OCISodaReplOneAndGet() |
Replaces a document in a collection. The input document is represented only by the content string. |
OCISodaReplOneAndGetWithCtnt() |
Replaces a document in a collection and returns the result document. The input document is represented only by the content string. |
OCISodaReplOneAndGetWithKey() |
Replace a document in a collection given a key and returns the result document. |
OCISodaReplOneWithCtnt() |
Replaces a document in a collection. The document is represented only by the content string |
OCISodaReplOneWithKey() |
Replaces a document in a collection given a key. |
OCISodaSave() |
Saves a document into a collection. |
OCISodaSaveAndGet() |
Saves a document into a collection, returning a document containing metadata information. |
OCISodaSaveAndGetWithOpts
() |
Saves a SODA document with options. |
OCISodaOperKeysSet() |
Sets the array of keys on Operation Options Handle. |
OCISodaBulkInsert()
Inserts an array of documents into a collection.
Purpose
To insert an array of documents into a collection.
Syntax
sword OCISodaBulkInsert(OCISvcCtx *svchp,
OCISodaColl *collection,
OCISodaDoc **documentarray,
ub4 arraylen,
OCISodaOutputOptions *opoptns,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
collection (IN) |
The collection handle for an existing collection. |
documentarray (IN) |
Array of handles of documents to be inserted into the collection. |
arrarylen (IN) |
The length of the document handle array supplied in the
|
opoptns (OUT) |
Output options handle. Valid attributes are:
Note: If an error occurs, |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution.
Valid modes are:
|
Returns
OCI_SUCCESS
, if the document array insertion into the specified collection is successful.
OCI_ERROR
, if the document array insertion failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Inserting Documents into Collections with SODA for C
OCISodaBulkInsertAndGet()
Inserts an array of documents into a collection, and returns an array of result documents each containing all document components except for the content.
Purpose
To insert an array of documents into a collection, and return an array of result documents, each containing all document components except for the content. The components generated by SODA during the insert, such as key (if the collection has auto-assigned keys), last-modified timestamp, created-on timestamp, and version, are returned with each result document.
Syntax
sword OCISodaBulkInsertAndGet(OCISvcCtx *svchp,
OCISodaColl *collection,
OCISodaDoc **documentarray,
ub4 arraylen,
OCISodaOutputOptions *opoptns,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
collection (IN) |
The collection handle for an existing collection. |
documentarray (IN/OUT) |
Array of handles of documents to be inserted into the collection. Note: Since the result documents are returned using the same parameter, you need to save a reference to each input document handle so that you can free it later along with each result document handle, using |
arrarylen (IN) |
The length of the document handle array supplied in |
opoptns (OUT) |
Output options handle. Valid attributes are:
|
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document array insertion into the specified collection is successful.
OCI_ERROR
, if the document array insertion failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Inserting Documents into Collections with SODA for C.
OCISodaBulkInsertAndGetWithOpts()
Inserts several SODA documents with options.
Purpose
To insert several SODA documents with options.
Syntax
sword OCISodaBulkInsertAndGetWithOpts(OCISvcCtx *svchp,
OCISodaColl *collection,
OCISodaDoc **documentarray,
ub4 arraylen,
OCISodaOperationOptions *oproptns,
OCISodaOutputOptions *opoptns,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
collection (IN) |
The collection handle in which you want to insert. |
documentarray (IN/OUT) |
The document array to be inserted. |
arrarylen (IN) |
The length of the document array to be inserted. |
oproptns (IN) | Operation options handle. |
opoptns (OUT) |
Output options handle. |
errhp (IN) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the documents were inserted.
OCISodaBulkInsertAndGetWithCtnt()
Inserts an array of documents into a collection using only their contents, and returns an array of result documents containing all the document components except for the content.
Purpose
To insert an array of documents into a collection using only their contents and returns an array of result documents, each document containing all document components except for the content.
Note:
This is a convenience method for inserting JSON documents only without constructing document handles for them. The more general method isOCISodaBulkInsertAndGet
.
Syntax
sword OCISodaBulkInsertAndGetWithCont(OCISvcCtx *svchp,
OCISodaColl *collection,
void **contentStrings,
ub4 *contentStringLengths,
OraText **keys,
ub4 *keyLengths,
ub4 arrayLength,
ub4 docFlags,
OCISodaDoc **documents,
OCISodaOutputOptions *opoptns,
OCIError *errhp
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
collection (IN) |
The collection handle for an existing collection. |
contentStrings (IN) |
An array of strings that contains the JSON content for the documents. Note: This method works only for JSON documents. |
contentStringLengths (IN) |
An array of content string lengths. |
keys (IN) |
An array of keys for the inserted documents. Provide the keys, if the collection has client-assigned keys. Otherwise, set to null. |
keyLengths (IN) |
An array of key lengths. Needs to be set only if the collection has client-assigned keys. Otherwise, must be set to null. |
arrayLength (IN) |
The length of the |
docFlags (IN) |
The encoding flags used to indicate the encoding of the supplied document's content. Valid flag options are:
|
documents (OUT) |
Returns an array of result documents containing all document components except for the content. Each result document contains the components such as key (if the collection has auto-assigned keys), last-modified timestamp, created-on timestamp, and version generated by SODA insert command. |
opoptns (OUT) |
Specifies the output options handle. Valid attributes
are:
Note: If an error occurs, |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document insertion into the specified collection is successful.
OCI_ERROR
, if the document insertion failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Inserting Documents into Collections with SODA for C.
OCISodaBulkInsertWithCtnt()
Inserts an array of documents into a collection using only their contents.
Purpose
To insert an array of documents into a collection using only their contents.
Note:
This is a convenience method for inserting JSON documents only without constructing document handles for them. The more general method isOCISodaBulkInsert
.
Syntax
sword OCISodaBulkInsertWithCtnt(OCISvcCtx *svchp,
OCISodaColl *collection,
void **contentStrings,
ub4 *contentStringLengths,
OraText **keys,
ub4 *keyLengths,
ub4 arrayLength,
ub4 docFlags,
OCISodaOutputOptions *opoptns,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
collection (IN) |
The collection handle for an existing collection. |
contentStrings (IN) |
An array of strings that contain the JSON content for the documents. This method works only for JSON documents. |
contentStringLengths (IN) |
An array of content string lengths. |
keys (IN) |
An array of keys for the inserted documents. Provide the keys, if the collection has client-assigned keys. Otherwise, set to null. |
keyLengths (IN) |
An array of key lengths. Needs to be set only if the collection has client-assigned keys. Otherwise, must be set to null. |
arrayLength (IN) |
The length of the |
docFlags (IN) |
The encoding flags used to create the documents. Valid flag options are:
|
opoptns (OUT) |
Specifies the output options handle. Valid attributes
are:
Note: If an error occurs, |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document insertion into the specified collection is successful.
OCI_ERROR
, if the document insertion failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For example, see Inserting Documents into Collections with SODA for C
OCISodaCollCreate()
Creates a new document collection with default metadata settings.
Purpose
Create a new document collection with default metadata settings.
Syntax
sword OCISodaCollCreate(OCISvcCtx *svchp,
const OraText *collname,
ub4 collnamelen,
OCISodaColl **collection,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collname (IN) |
The name of the collection. |
collnamelen (IN) |
The length of the collection name. |
collection (OUT) |
Allocates the collection handle representing the document collection that was created. Call |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the collection is successfully created.
OCI_ERROR
, if the collection is not created. The OCIError
parameter has the necessary error information.
Usage Notes
-
If the collection with the specified name already exists, then this function acts as
OCISodaCollOpen()
and opens the existing collection. -
This function, unlike a SQL DDL operation, does not perform a commit operation before or after it runs. (Unless you specify
OCI_SODA_ATOMIC_COMMIT
mode, only then is the current transaction committed after the operation runs).
Examples
Example 36-1 Creating a Collection
for examples, see Creating a Document Collection for SODA with C.
OCISodaCollCreateWithMetadata()
Creates a new document collection with metadata.
Purpose
Create a new document collection with metadata.
Syntax
sword OCISodaCollCreateWithMetadata(OCISvcCtx *svchp,
const OraText *collname,
ub4 collnamelen,
OraText *metadata,
ub4 metadatalen,
OCISodaColl **collection,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collname (IN) |
The name of the collection. |
collnamelen (IN) |
The length of the collection name. |
metadata (IN) |
The JSON string that contains the collection metadata information. If |
metadatalen (IN) |
The length of the metadata JSON string. |
collection (OUT) |
Allocates the collection handle representing the document collection that was created. Call |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the collection is successfully created.
OCI_ERROR
, if the collection is not created. The OCIError
parameter has the necessary error information.
Usage Notes
-
If the collection with the specified name already exists and that collection has metadata equivalent to the supplied metadata, then this function acts as
OCISodaCollOpen()
and opens the existing collection. If the collection contains metadata that does not match with the specified collection name, then an error is returned. -
This function, unlike a SQL DDL operation, does not perform a commit operation before or after it runs. (Unless you specify
OCI_SODA_ATOMIC_COMMIT
mode, only then is the current transaction committed after the operation runs).
Examples
For example, see Creating a Document Collection for SODA with C.
OCISodaCollDrop()
Drops a collection from the database.
Purpose
Drop a collection from the database.
Syntax
sword OCISodaCollDrop(OCISvcCtx *svchp,
OCISodaColl *coll,
boolean *isDropped,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
coll (IN) |
The collection to be dropped. If |
isDropped (OUT) |
Returns the status of the drop operation: |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if dropping the collection is successful.
OCI_ERROR
, if dropping the collection failed. The OCIError
parameter has the necessary error information.
Usage Notes
-
This function only drops the collection; it does not free the collection handle. Call
OCIHandleFree()
to free the collection handle to avoid memory leaks. -
This function, unlike a SQL DDL operation, does not perform a commit operation before or after it runs. (Unless you specify
OCI_SODA_ATOMIC_COMMIT
mode, only then is the current transaction committed after the operation runs).
Examples
For examples, see Dropping a Document Collection with SODA for C.
OCISodaCollGetNext()
Gets the next collection from the collection cursor.
Purpose
Get the next collection from the collection cursor.
Syntax
sword OCISodaCollGetNext(OCISvcCtx *svchp,
const OCISodaCollCursor *cur,
OCISodaColl **coll,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
cur (IN) |
The collection cursor handle remains valid when allocated by |
coll (OUT) |
Allocates the collection handle and returns it to the next collection to be found. Call |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the next collection is returned from the specified cursor.
OCI_ERROR
, if there was an error fetching the next collection. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Discovering Existing Collection with SODA for C
OCISodaCollList()
Lists the collections in the schema associated with the supplied service context handle parameter.
Purpose
List the collections in the schema.
Syntax
sword OCISodaCollList(OCISvcCtx *svchp,
const OraText *startname,
ub4 stnamelen,
OCISodaCollCursor **cur,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
startname (IN) |
The collection start name. Can be set to |
stnamelen (IN) |
The length of the collection start name. |
cur (OUT) |
Allocates the collection cursor handle and returns it. The collection cursor represents the collection list. Call |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if getting a cursor over all collections in the schema is successful.
OCI_ERROR
, if getting a cursor over all collections in the schema is not successful. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Discovering Existing Collection with SODA for C.
OCISodaCollOpen()
Opens the collection.
Purpose
Open the collection.
Syntax
sword OCISodaCollOpen(OCISvcCtx *svchp,
const OraText *collname,
ub4 collnamelen,
OCISodaColl **coll,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collname (IN) |
The name assigned to the collection. |
collnamelen (IN) |
The length of the collection name. |
coll (OUT) |
Allocates the collection handle and returns it with the specified collection name. The function returns |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if there were no errors while trying to open the collection.
OCI_ERROR
, if errors were encountered while trying to open the collection. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Opening an Existing Document Collection with SODA for C.
OCISodaDataGuideGet()
Gets JSON data guide information.
Purpose
To get the JSON data guide information.
Syntax
sword OCISodaDataGuideGet(OCISvcCtx *svchp,
const OCISodaColl *collection,
ub4 docFlags,
OCISodaDoc **doc,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
collection(IN) |
The collection handle. |
docFlags (IN) |
The following flags control the
encoding of the returned document's content. Valid
flag options are:
|
doc (OUT) |
The document handle with content representing the JSON data guide. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if getting the data guide information of a specified collection is successful.
OCI_ERROR
, if getting data guide information results in an error. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Getting a Data Guide for a Collection with SODA for C.
OCISodaDataGuideGetWithOpts ()
For only the documents selected from your query, a data guide is created guide dynamically from scratch. Dataguide enabled JSON search index is not required.
Purpose
To get data guide.
Syntax
sword OCISodaDataGuideGetWithOpts(OCISvcCtx *svchp,
const OCISodaColl *collection,
OCISodaOperationOptions *optns,
ub4 format,
ub4 flags,
ub4 docFlags,
OCISodaDoc **doc,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
collection(IN) |
The collection handle in which you want to intert. |
optns (IN) | Operation options handle. |
format (IN) | OCI SODA DataGuide formats:
|
flags (IN) | OCI SODA DataGuide flags:
|
docflags (IN) | Document flags. |
doc (OUT) | Document. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution.
Valid modes are:
|
Returns
OCI_SUCCESS
, if data guide is retrieved.
OCISodaAsOfTimestampGet ()
Fetches the database timestamp value as a string.
Purpose
To fetch the database timestamp value as a string.
Syntax
sword OCISodaAsOfTimestampGet(OCISvcCtx *svchp,
void *tstamp,
ub4 *tstampLen,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
tstamp (IN/OUT) |
The Database timestamp value. |
tstampLen (OUT) |
Length of timestamp string. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. |
Returns
OCI_SUCCESS
, if the operation is successful.
OCI_ERROR
, if getting data guide information results in an error. The OCIError
parameter has the necessary error information.
Usage Notes
The input timestamp buffer (tstamp
) is expected to be atleast
OCI_SODA_TIMESTAMP_MAXSIZE
in
size. If OCI_UTF16ID
is specified
for SQL CHAR data in the
OCIEnvNlsCreate()
function, then
tstamp
is expected to be
utext
array of
OCI_SODA_TIMESTAMP_MAXSIZE
size,
that is Utext
tstamp[OCI_SODA_TIMESTAMP_MAXSIZE]
.
OCISodaAsOfScnGet ()
Fetches the database SCN value.
Purpose
To fetch the database SCN value.
Syntax
sword OCISodaAsOfScnGet(OCISvcCtx *svchp,
ub8 *scn,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
scn (OUT) |
Database SCN value. |
errhp (IN) |
The error handle. |
mode (IN) |
Specifies the mode of execution.
Valid modes are:
|
Returns
OCI_SUCCESS
if
the operation is successful.
OCISodaDocCount()
Counts the number of documents matching the attributes set in the operation options handle. If the operation options handle has no attributes set, then the function counts all the documents in the collection.
Purpose
To count the number of documents matching the attributes set in the operation options handle. If the operation options handle has no attributes set, then the function counts all the documents in the collection.
Syntax
sword OCISodaDocCount(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OCISodaOperationOptions *optns,
ub8 *numdocs,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
coll (IN) |
The collection handle for an existing collection. |
optns (IN) |
The operation options handle. If skip and limit attributes are set on the operation options handle, then an error is returned. |
numdocs (OUT) |
The number of documents in the collection matching attributes (if any) set on the operation options handle. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the
mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document
count from the specified collection is
successful.
OCI_ERROR
, if the document count
failed due to hard errors. The
OCIError
parameter has the
necessary error information.
Usage Notes
None.
Examples
For examples, see Counting the Number of Documents Found.
OCISodaDocCountWithFilter()
Counts the number of documents matching a filter specification.
Purpose
To count the number of documents matching a filter specification.
Note:
This is a convenience method for counting documents matching a filter specification. A more general method for counting documents isOCISodaDocCount()
which can count documents matching a filter
specification or other criteria.
Syntax
sword OCISodaDocCountWithFilter(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OraText *filterSpec,
ub4 filterSpecLen,
ub8 *numdocs,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
coll (IN) |
The collection handle for an existing collection. |
filterSpec (IN) |
The JSON filter string used to search the documents in a collection. |
filterSpecLen (IN) |
The length of the filter string. |
numdocs (OUT) |
The number of documents in the collection matching the filter. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document count from the specified collection is successful.
OCI_ERROR
, if the document count failed due to hard errors. The OCIError
parameter has the necessary error information.
Usage Notes
None.
OCISodaDocCreate()
Creates a document.
Purpose
Create a document.
Syntax
sword OCISodaDocCreate (OCIEnv *envhp,
const void *content,
ub4 contentLength,
ub4 docFlags,
OCISodaDoc **document,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
envhp (IN) |
The environment handle. |
content(IN) |
A string containing the document content. |
contentLength (IN) |
The string length of the content parameter. |
docFlags (IN) |
Used to detect JSON encoding while creating a document. Valid flag options are:
|
document (OUT) |
Allocates and returns the document handle. Call |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is successfully created.
OCI_ERROR
, if the document creation failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
Example 36-2 Creating a Document
For examples, see Creating Documents with SODA for C.
OCISodaDocCreateWithKey()
Creates a document with a document key and content.
Purpose
Create a document with a document key and content.
Syntax
sword OCISodaDocCreateWithKey(OCIEnv *envhp,
const void *content,
ub4 contentLength,
const OraText *key,
ub4 keylen,
ub4 docFlags,
OCISodaDoc **document,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
envhp (IN) |
The environment handle. |
content (IN) |
A string containing the document content. |
contentLength (IN) |
The string length of the content parameter. |
key (IN) |
A string that contains the document key. The key can be For example, in the default case, collection has auto-generated keys, so you do not want to set the key on the document (if you do, you get an error when you pass such a doc to a write operation, such as insert). You only want to set a non- |
keylen (IN) |
The length of the key string. |
docFlags (IN) |
The flags used to create a document. Valid flag options are:
|
document (OUT) |
Allocates and returns the document handle. Call |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is successfully created.
OCI_ERROR
, if the document creation failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Creating Documents with SODA for C.
OCISodaDocCreateWithKeyAndMType()
Creates a document with a document key, content, and media type.
Purpose
Create a document with a document key, content, and media type.
Syntax
sword OCISodaDocCreateWithKeyAndMType(OCIEnv *envhp,
const void *content,
ub4 contentLength,
const OraText *key,
ub4 keylen,
const OraText *mediaType,
ub4 mediaTypeLength,
ub4 docFlags,
OCISodaDoc **document,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
envhp (IN) |
The environment handle. |
content (IN) |
A string containing the document content. |
contentLength (IN) |
The string length of the content parameter. |
key (IN) |
A string that contains the document key. The key can be For example, in the default case, collection has auto-generated keys, so you do not want to set the key on the document (if you do, you get an error when you pass such a doc to a write operation, such as insert). You only want to set a non- |
keylen (IN) |
The length of the key string. |
mediaType (IN) |
A string that contains the document media type. If no media type value is specified, it defaults to " |
mediaTypeLength (IN) |
The length of the media type string. |
docFlags (IN) |
The flags used to create the document. Valid flag options are:
|
document (OUT) |
Allocates and returns the document handle. Call |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is successfully created.
OCI_ERROR
, if the document creation failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Creating Documents with SODA for C.
OCISodaDocGetNext()
Gets the next document from the cursor.
Purpose
To get the next document from the cursor.
Syntax
sword OCISodaDocGetNext(OCISvcCtx *svchp,
const OCISodaDocCursor *cursor,
OCISodaDoc **doc,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
cursor (IN) |
The cursor for the document results. |
doc (OUT) |
The document handle returned by the cursor. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is found in the specified collection.
OCI_ERROR
, if the document search failed. The OCIError
parameter has the necessary error information.
OCI_NO_DATA
, if data not found. (exit criteria).
Usage Notes
None.
Examples
for examples, see Finding Documents in Collections with SODA for C.
OCISodaFind()
Finds the documents in a collection matching the attributes set in operation options input handle. If no conditions are set, all the documents in the collection are returned.
Purpose
To find the documents in a collection matching the attributes set in operation options input handle. If no conditions are set, then all the documents in the collection are returned.
Syntax
sword OCISodaFind(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OCISodaOperationOptions *findOptions,
ub4 docFlags,
OCISodaDocCursor **cursor,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
coll (IN) |
The collection to search for the documents. |
findOptions (IN) |
The operation options handle with attributes to drive the find operation. If no attributes are set, then all the documents in the collection are returned. |
docFlags (IN) |
The following flags control the encoding of the returned document's content. Valid flag options are
|
cursor (OUT) |
The cursor for the document results. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is found in the specified collection.
OCI_ERROR
, in case of hard errors. The OCIError
parameter has the necessary error information.
OCI_NO_DATA
, if data not found. (exit criteria).
Usage Notes
None.
Examples
For examples, see Finding Documents in Collections with SODA for C.
OCISodaFindOne()
Finds the document in a collection matching the attributes set in operation options input handle. If more than one document in the collection matches the attributes set, then the first document is returned.
Purpose
To find the document in a collection matching the attributes set in operation options input handle. If more than one document in the collection matches the attributes set, then the first document is returned.
Syntax
sword OCISodaFindOne(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OCISodaOperationOptions *findOptions,
ub4 docFlags,
OCISodaDoc **doc,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
coll (IN) |
The collection to search for the documents. |
findOptions (IN) |
The operation options handle with attributes to drive the find operation. If more than one document in the collection matches, then the first matching document is returned. |
docFlags (IN) |
The following flags control the encoding of the returned document's content. Valid flag options are:
|
doc (OUT) |
The document found (returns |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is found in the specified collection.
OCI_ERROR
, if the document search failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Finding Documents in Collections with SODA for C.
OCISodaFindOneWithKey()
Finds a single document in a collection, given a key.
Purpose
To find a single document in a collection, given a key.
Note:
This is a convenience method for finding a document by a key. A more general method isOCISodaFindOne.
Syntax
sword OCISodaFindOneWithKey(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OraText *key,
ub4 keylen,
ub4 docFlags,
OCISodaDoc **doc,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
coll (IN) |
The collection to search for the document. |
key (IN) |
The key used to identify the document. |
keylen (IN) |
The length of the key. |
docFlags (IN) |
The following flags control the encoding of the returned document's content. Valid flag options are:
|
doc (OUT) |
Allocates and returns the document handle if the document is found in the collection. If the document is not found in the collection, a |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is found in the specified collection.
OCI_NO_DATA
, if the document was not found.
OCI_ERROR
, if there was an error in trying to find the document. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Finding Documents in Collections with SODA for C
OCISodaIndexCreate()
Creates an index with an index specification.
Purpose
To create an index with an index specification. The following three types of index specifications can be supplied, B-tree, JSON search index, and spatial.
Syntax
sword OCISodaIndexCreate(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OraText *indexspec,
ub4 speclen,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
coll (IN) |
The handle for the collection to be indexed. |
indexspec (IN) |
The index specification. |
speclen(IN) |
The index specification length. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if index creation on the specified collection is successful.
OCI_ERROR
, if index creation results in an error. The OCIError
parameter has the necessary error information.
Usage Notes
This function, unlike a SQL DDL operation, does not perform a commit operation before or after it runs. (Unless you specify OCI_SODA_ATOMIC_COMMIT mode, only then is the current transaction committed after the operation runs).
Examples
For examples, see Indexing the Documents in a Collection with SODA for C.
Related Topics
OCISodaIndexDrop()
Drops an index.
Purpose
To drop an index.
Syntax
sword OCISodaIndexDrop(OCISvcCtx *svchp,
OraText *indexname,
ub4 indexnamelen,
boolean *isDropped,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
indexname (IN) |
The index name. |
indexnamelen(IN) |
The index name length. |
isDropped (OUT) |
Returns the status of the drop operation:
|
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if dropping an index on specified collection is successful.
OCI_ERROR
, if dropping an index results in an error. The OCIError
parameter has the necessary error information.
Usage Notes
This function, unlike a SQL DDL operation, does not perform a commit operation before
or after it runs. (Unless you specify
OCI_SODA_ATOMIC_COMMIT
mode, only
then is the current transaction committed after
the operation runs).
Examples
For example, see Dropping an Index with SODA for C.
OCISodaInsert()
Inserts a document into a collection.
Purpose
Insert a document into a collection.
Syntax
sword OCISodaInsert(OCISvcCtx *svchp,
OCISodaColl *collection,
OCISodaDoc *document,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
The collection handle for an existing collection. |
document (IN) |
The handle of the document that is to be inserted into the collection. |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document insertion into the specified collection is successful.
OCI_ERROR
, if the document insertion failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Inserting Documents into Collections with SODA for C.
OCISodaInsertAndGet()
Inserts a document into a collection, returning a result document containing all document components except for content.
Purpose
Insert a document into a collection, returning a result document containing all document components except for content. The components generated by SODA during the insert, such as key (if the collection has auto-assigned keys), last-modified timestamp, created-on timestamp, and version, are returned as part of the result document.
Syntax
sword OCISodaInsertAndGet(OCISvcCtx *svchp,
OCISodaColl *collection,
OCISodaDoc **document,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
The collection handle for an existing collection. |
document (IN/OUT) |
The handle of the document that is to be inserted into the collection. Returns the result document through this same parameter as it is an Caution: Because the result document is returned using the same parameter, you need to save a reference to the input document handle so that you can free it later, along with the result document handle, using |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document insertion into the specified collection is successful.
OCI_ERROR
, if the document insertion failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Inserting Documents into Collections with SODA for C.
OCISodaInsertAndGetWithOpts ()
Inserts a SODA document with options.
Purpose
To insert a SODA document with options.
Syntax
sword OCISodaInsertAndGetWithOpts(OCISvcCtx *svchp,
OCISodaColl *collection,
OCISodaDoc **document,
OCISodaOperationOptions *oproptns,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
The collection handle in which you want to insert. |
document (IN/OUT) |
Document handle to be inserted and returned. |
oproptns (IN) | Operation options handle |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution.
Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is inserted.
OCISodaInsertAndGetWithCtnt()
Inserts a document into a collection using just the content, returning a result document containing all document components except for content.
Purpose
Insert a document into a collection using just the content, returning a result document containing all document components except for content. The components generated by SODA during the insert, such as key (if the collection has auto-assigned keys), last-modified timestamp, created-on timestamp, and version, are returned as part of the result document.
Note:
This is a convenience method for inserting a JSON document without constructing a document handle for them. A more general method isOCISodaInsertAndGet
.
Syntax
sword OCISodaInsertAndGetWithCtnt(OCISvcCtx *svchp,
OCISodaColl *collection,
const OraText *key,
ub4 keyLength,
const void *content,
ub4 contentLength,
ub4 docFlags,
OCISodaDoc **document,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
The collection handle for an existing collection. |
key (IN) |
A string that contains the document key. Must be |
keyLength (IN) |
The length of the key string. Must be 0 if inserting a document into a collection configured for auto-generated keys. |
content (IN) |
A string containing the JSON content for the document. Note: This method works only for JSON documents. |
contentLength (IN) |
The string length of the |
docFlags (IN) |
The encoding flags used to indicate the encoding of the supplied document's content. Valid flag options are:
|
document (OUT) |
Allocates and returns a result document containing all document components except for content. The components generated by SODA during the insert, such as key (if the collection has auto-assigned keys), last-modified timestamp, created-on timestamp, and version, are returned as part of the result document. If |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document insertion into the specified collection is successful.
OCI_ERROR
, if the document insertion failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Inserting Documents into Collections with SODA for C
OCISodaInsertWithCtnt()
Inserts a document into a collection using only the content.
Purpose
Insert a document into a collection using only the content.
Note:
This is a convenience method for inserting a JSON document without constructing a document handle for them. A more general method isOCISodaInsert
.
Syntax
sword OCISodaInsertWithCtnt(OCISvcCtx *svchp,
OCISodaColl *collection,
const OraText *key,
ub4 keyLength,
const void *content,
ub4 contentLength,
ub4 docFlags,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
The collection handle for an existing collection. |
key (IN) |
A string that contains the document key. Must be |
keyLength (IN) |
The length of the key string. Must be 0 if inserting a document into a collection configured for auto-generated keys. |
content (IN) | A string containing the JSON content for the document.
Note: This method works only for JSON documents. |
contentLength (IN) |
The length of the document content. |
docFlags (IN) |
The encoding flags used to indicate the encoding of the supplied document's content. Valid flag options are:
|
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document insertion into the specified collection is successful.
OCI_ERROR
, if the document insertion failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Inserting Documents into Collections with SODA for C.
OCISodaRemove()
Removes the documents matching the attributes set in operation options input handle from the collection. If no attributes are set, then all the documents in the collection are removed.
Purpose
To remove the documents matching the attributes set in operation options input handle from the collection. If no attributes are set, then all the documents in the collection are removed.
Syntax
sword OCISodaRemove(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OCISodaOperationOptions *optns,
ub8 *removeCount,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
coll (IN) |
The collection handle for an existing collection. |
optns (IN) |
The operation options handle with attributes to drive the remove operation. If no
attributes are set, all the documents in the
collection are removed. If
|
removeCount (OUT) |
The number of documents removed. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if one or more documents are removed from the specified collection.
OCI_ERROR
, if the document removal failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Removing Documents from a Collection with SODA for C
OCISodaRemoveOneWithKey()
Removes a document from a collection given a key.
Purpose
Remove a document from a collection given a key.
Note:
This is a convenience method for removing a document with a single key. A more general method isOCISodaRemove
.
Syntax
sword OCISodaRemoveOneWithKey(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OraText *key,
ub4 keylength,
boolean *isRemoved,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
coll (IN) |
The collection handle for an existing collection. |
key (IN) |
The key of the document to be removed. |
keylength (IN) |
The length of key of the document to be removed. |
isRemoved (OUT) |
Returns |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document with the specified key was not found. OCI_SUCCESS
is still returned (and isRemoved
will be set to FALSE
). Check that the isRemoved
parameter is set to TRUE
to know whether the document has been removed.
OCI_ERROR
, if the document removal operation failed during execution due to a SQL error. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Removing Documents from a Collection with SODA for C.
OCISodaReplOne()
Replaces a document matching the attributes set in operation options input handle.
Purpose
To replace a document matching the attributes set in operation options input handle.
In order to uniquely identify the document to be
replaced, at least
OCI_ATTR_SODA_KEY
key must be set
in operation options. Other attributes can also be
set.
Syntax
sword OCISodaReplOne(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OCISodaOperationOptions *optns,
OCISodaDoc *document,
boolean *isReplaced,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
coll (IN) |
The collection handle for an existing collection. |
optns (IN) |
The operation options handle with attributes to drive the replace operation. At
least the key, |
document (IN) |
The document handle to use as the replacement of the document currently in the collection. Only the content and media type component from this handle is used during the replace operation (that is, this operation replaces the content and media type of the document in the collection). Other components, if set on the input document, are ignored. |
isReplaced (OUT) |
Whether the document is replaced or not. Returns |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, document is replaced in the specified collection.
OCI_ERROR
, if the document replacment failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Replacing Documents in a Collection with SODA for C.
OCISodaReplOneAndGet()
Replaces a document matching the attributes set in operation options input handle, and returns the handle to the result document.
Purpose
To replace a document matching the attributes set in operation options input handle,
and returns the handle to the result document. In
order to uniquely identify the document to be
replaced, at least
OCI_ATTR_SODA_KEY
key must be set
in operation options. Other attributes can also be
set.
Syntax
sword OCISodaReplOneAndGet(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OCISodaOperationOptions *optns,
OCISodaDoc **document,
boolean *isReplaced,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
coll (IN) |
The collection handle for an existing collection. |
optns (IN) |
The operation options handle with attributes to drive the replace operation. At least
the key, |
document (IN/OUT) |
The document handle to use as the replacement of the document currently in the collection. Only the content and media type component from this handle is used during the replace operation (that is, this operation replaces the content and media type of the document in the collection). Other components, if set on the input document, are ignored. Returns the result document through this same parameter as it is an Caution: Because the result document is returned using the same parameter, you need to save a reference to the input document handle so that you can free it later, along with the result document handle, using |
isReplaced (OUT) |
Whether the document is replaced or not. Returns |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is replaced in the specified collection.
OCI_ERROR
, if the document replacement failed due to hard errors. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Replacing Documents in a Collection with SODA for C.
OCISodaReplOneAndGetWithCtnt()
Replaces the content of the document matching the attributes set in operation options input handle with new content, and returns the handle to the result document.
Purpose
To replace the content of the document matching the attributes set in operation
options input handle with new content, and returns the handle to the result document
containing all components except for the content, including the updated ones, such
as the last-modified timestamp and version. In order to uniquely identify the
document to be replaced, at least OCI_ATTR_SODA_KEY
key must be set
in operation options. Other attributes can also be set.
Note:
This is a convenience method for replacing a document with a JSON document without constructing a document handle for the replacement document. A more general method isOCISodaReplOneAndGet
. This method
is only for JSON documents. That is, the supplied
replacement document must be a JSON document and
the target document that is being replaced in the
collection may or may not be a JSON
document.
Syntax
sword OCISodaReplOneAndGetWithCtnt(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OCISodaOperationOptions *optns,
const void *content,
ub4 contentLen,
ub4 docFlags,
OCISodaDoc **document,
boolean *isReplaced,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
coll (IN) |
The collection handle for an existing collection. |
optns (IN) |
The operation options handle with attributes to drive the replace operation. At
least the key, |
content (IN) |
A string containing the JSON content of the document. Note: This method works only for JSON documents. |
contentLen (IN) |
The length of the document content. |
docFlags (IN) |
The encoding flags used to indicate the encoding of the supplied document's content. Valid flag options are:
|
document (OUT) |
Result document contains all components except for the content, including the updated ones, such as the last-modified timestamp and version. |
isReplaced (OUT) |
Whether the document is replaced or not. Returns |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is replaced in the specified collection.
OCI_ERROR
, if the document replacement failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Replacing Documents in a Collection with SODA for C.
OCISodaReplOneAndGetWithKey()
Replaces a document in a collection given a key and returns the handle to the result document.
Purpose
To replace a document in a collection given a key and return the handle to the result document containing all components except content, including the updated ones, such as the last-modified timestamp and version.
Note:
This is a convenience method for replacing a document by a key. A more general method isOCISodaReplOneAndGet
.
Syntax
sword OCISodaReplOneAndGetWithKey(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OraText *key,
ub4 keylength,
OCISodaDoc **document,
boolean *isReplaced,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
coll (IN) |
The collection handle for an existing collection. |
key (IN) |
The key used to identify the document. |
keylength (IN) |
The length of the key. |
document (IN/OUT) |
The document handle to use as the replacement of the document currently in the collection. Only the content and media type component from this handle is used during the replace operation (that is, this operation replaces the content and media type of the document in the collection). Other components, if set on the input document, are ignored. Returns the result document through this same parameter as it is an Caution: Because the result document is returned using the same parameter, you need to save a reference to the input document handle so that you can free it later, along with the result document handle, using |
isReplaced (OUT) |
Returns |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document with the specified key was not found. OCI_SUCCESS
is still returned (and isReplaced
will be set to FALSE
). Check that the isReplaced
parameter is set to TRUE
to know whether the document has been replaced.
OCI_ERROR
, if the document replacement operation failed during execution due to a SQL error. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Replacing Documents in a Collection with SODA for C
OCISodaReplOneWithCtnt()
Replaces the content of the document matching the attributes set in operation options input handle with new content.
Purpose
To replace the content of the document matching the attributes set in operation
options input handle with new content. In order to
uniquely identify the document to be replaced, at
least OCI_ATTR_SODA_KEY
key must
be set in operation options. Other attributes can
also be set.
Note:
This is a convenience method for replacing a document with a JSON document without constructing a document handle for the replacement document. A more general method isOCISodaReplOne
. This method is
only for JSON documents. That is, the supplied replacement document
must be a JSON document and the target document that is being
replaced in the collection may or may not be a JSON document.
Syntax
sword OCISodaReplOneWithCtnt(OCISvcCtx *svchp,
const OCISodaColl *coll,
const OCISodaOperationOptions *optns,
const void *content,
ub4 contentLength,
ub4 docFlags,
boolean *isReplaced,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context. |
coll (IN) |
The collection handle for an existing collection. |
optns (IN) |
The operation options handle with attributes to drive the replace operation. At
least the key, |
content (IN) |
A string containing the JSON content of the document. Note: This method works only for JSON documents. |
contentLength (IN) |
The length of the document content. |
docFlags (IN) |
The encoding flags used to indicate the encoding of the supplied document's content. Valid flag options are:
|
isReplaced (OUT) |
Whether the document is replaced or not. Returns |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution.
Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is replaced in the specified collection.
OCI_ERROR
, if the document replacement failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Replacing Documents in a Collection with SODA for C.
OCISodaReplOneWithKey()
Replaces a document in a collection given a key.
Purpose
To replace a document in a collection given a key.
Note:
This is a convenience method for replacing a document by a key. A more general method isOCISodaReplOne.
Syntax
sword OCISodaReplOneWithKey (OCISvcCtx *svchp,
const OCISodaColl *coll,
const OraText *key,
ub4 keylength,
OCISodaDoc *document,
boolean *isReplaced,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
coll (IN) |
The collection handle for an existing collection. |
key (IN) |
The key used to identify the document. |
keylength (IN) |
The length of the key. |
document (IN) |
The document handle to use as the replacement of the document currently in the collection. Only the content and media type component from this handle is used during the replace operation (that is, this operation replaces the content and media type of the document in the collection). Other components, if set on the input document, are ignored. |
isReplaced (OUT) |
Returns |
errhp (IN/OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document with the specified key was not found. OCI_SUCCESS
is still returned (and isReplaced
will be set to FALSE
). Check that the isReplaced
parameter is set to TRUE
to know whether the document has been replaced.
OCI_ERROR
, if the document replacement operation failed during execution due to a SQL error. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
For examples, see Replacing Documents in a Collection with SODA for C
OCISodaSave()
Saves a document into a collection.
Purpose
Save a document into a collection.
This function is equivalent to insert function except that if the client-assigned keys are used, or the document with the specified key already exists in the collection, then it is replaced with the input document. The key is automatically created, unless this collection is configured with client-assigned keys and the key is provided in the input document.Syntax
sword OCISodaSave(OCISvcCtx *svchp,
OCISodaColl *collection,
OCISodaDoc *document,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
An opened collection. |
document (IN) |
The document handle that is used to insert the content into the collection. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document save into the specified collection is successful.
OCI_ERROR
, if the document save failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
See the example in OCISodaDocCreateWithKeyAndMType().
OCISodaSaveAndGet()
Saves a document into a collection, returning a document containing metadata information.
Purpose
Save a document into a collection, returning a document containing metadata information, such as key, version, and timestamp information.
This function is equivalent to insert function except that if the client-assigned keys are used, or the document with the specified key already exists in the collection, then it is replaced with the input document. The key is automatically created, unless this collection is configured with client-assigned keys and the key is provided in the input document.
Syntax
sword OCISodaSaveAndGet(OCISvcCtx *svchp,
OCISodaColl *collection,
OCISodaDoc **document,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
An opened collection. |
document (IN/OUT) |
The document structure that is saved into the collection. If the key parameter in the call to |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document save into the specified collection is successful.
OCI_ERROR
, if the document save failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
See the example in OCISodaDocCreateWithKeyAndMType().
OCISodaSaveAndGetWithOpts()
Saves a SODA document with options.
Purpose
To save a SODA document with options.
Syntax
sword OCISodaSaveAndGetWithOpts(OCISvcCtx *svchp,
OCISodaColl *collection,
OCISodaDoc **document,
OCISodaOperationOptions *oproptns,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
The collection handle in which you want to insert. |
document (IN/OUT) |
The document handle to be inserted and returned. |
oproptns (IN) | Operation options handle. |
errhp (IN) |
The error handle. |
mode (IN) |
Specifies the mode of execution.
Valid modes are:
|
Returns
OCI_SUCCESS
, if the document is saved.
OCISodaSaveWithCtnt()
Saves a document into a collection with its content.
Purpose
To save the document which has specified keys.
This function is equivalent to insert function except that if the client-assigned keys are used, or the document with the specified key already exists in the collection, then it is replaced with the input document. The key is automatically created, unless this collection is configured with client-assigned keys and the key is provided in the input document.
Syntax
sword OCISodaSaveWithCtnt(OCISvcCtx *svchp,
OCISodaColl *collection,
const OraText *key,
ub4 keylength,
const void *content,
ub4 contentlen,
ub4 docFlags,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
An opened collection. |
key (IN) |
The specified key of the document to be saved. |
keylength(IN) |
The length of the key. |
content (IN) |
A string that contains |
contentlen(IN) |
The length of the |
docFlags (IN) |
The encoding flags used to save the document. Valid flag options are:
|
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the collection is successfully created.
OCI_ERROR
, if the collection is not created. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
See the example in OCISodaDocCreateWithKeyAndMType().
OCISodaSaveAndGetWithCtnt()
Saves a document into a collection and gets the new document handle.
Purpose
Saves the document which has specified keys and new document handle to obtain the saved documents.
This function is equivalent to insert function except that if the client-assigned keys are used, or the document with the specified key already exists in the collection, then it is replaced with the input document. The key is automatically created, unless this collection is configured with client-assigned keys and the key is provided in the input document.
Syntax
sword OCISodaSaveAndGetWithCont(OCISvcCtx *svchp,
OCISodaColl *collection,
const OraText *key,
ub4 keylength,
const void *content,
ub4 contentlen,
ub4 docFlags,
OCISodaDoc **document,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
An opened collection. |
key (IN) |
The specified key for the document to be saved. |
keylength(IN) |
The length of the key. |
content (IN) |
A string that contains content of the document. |
contentlen(IN) |
The length of the |
docFlags (IN) |
The encoding flags used to save the document. Valid flag options are:
|
document (IN/OUT) |
The document handle containing metadata of the saved document. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the document insertion into the specified collection is successful.
OCI_ERROR
, if the document insertion failed. The OCIError
parameter has the necessary error information.
Usage Notes
None.
Examples
See the example in OCISodaDocCreateWithKeyAndMType().
OCISodaCollTruncate()
Truncates a SODA document collection.
Purpose
Truncates the document collection.
sword OCISodaCollTruncate (OCISvcCtx *svchp,
const OCISodaColl *collection,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
svchp (IN) |
The service context handle. |
collection (IN) |
The collection handle for the collection you want to truncate. |
errhp (OUT) |
The error handle. |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
An Oracle return error code.
Usage Notes
None.
OCISodaOperKeysSet()
Sets an array of keys on Operation Options Handle.
Purpose
Sets an array of keys on Operation Options Handle. Attributes of the operation options
handle are set with standard OCIAttrSet
function. The
OCIAttrSet
function is not used to set the array of keys, because both
the array of keys and the array of key lengths need to be set.
Note:
If you use functionOCIAttrSet()
to set attribute
OCI_ATTR_SODA_KEY
on an operation-options handle, and you also use
function OCISodaOperKeysSet()
to set multiple keys on the same handle, then
only the latest of the two settings takes effect. The effect of the first function invoked
is overridden by the effect of the second.
Syntax
sword OCISodaOperKeysSet (const OCISodaOperationOptions *operhp,
OraText **keysArray,
ub4 *lengthsArray,
ub4 count,
OCIError *errhp,
ub4 mode);
Parameters
Parameter | Description |
---|---|
operhp (IN) |
Operation options handle |
keysArray (IN) |
Array of |
lengthsArray (IN) |
Array of |
count (IN) |
Number of elements in the keys array |
errhp (OUT) |
Error handle |
mode (IN) |
Specifies the mode of execution. Valid modes are:
|
Returns
OCI_SUCCESS
, if the keys were set successfully.
Usage Notes
None.
Examples
For examples, see Finding Multiple Documents with Specified Document Keys and Removing Documents from a Collection Using Document Keys.