oh_rdb_types.h
Overview
Defines types related to data values.
File to include: <database/rdb/oh_rdb_types.h>
Library: libnative_rdb_ndk.z.so
System capability: SystemCapability.DistributedDataManager.RelationalStore.Core
Since: 18
Related module: RDB
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| OH_RDB_ReturningContext | OH_RDB_ReturningContext | Context of the returning-related APIs. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| Rdb_ConflictResolution | Rdb_ConflictResolution | Enumerates the conflict resolution policies. |
Functions
| Name | Description |
|---|---|
| OH_RDB_ReturningContext *OH_RDB_CreateReturningContext(void) | Creates an OH_RDB_ReturningContext instance. |
| void OH_RDB_DestroyReturningContext(OH_RDB_ReturningContext *context) | Destroys an OH_RDB_ReturningContext instance. |
| int OH_RDB_SetReturningFields(OH_RDB_ReturningContext *context, const char *const fields[], int32_t len) | Sets the fields returned in the result set. |
| int OH_RDB_SetMaxReturningCount(OH_RDB_ReturningContext *context, int32_t count) | Sets the maximum number of rows for the returned result set. |
| OH_Cursor *OH_RDB_GetReturningValues(OH_RDB_ReturningContext *context) | Obtains the cursor of data changes, which contains 1,024 rows by default. |
| int64_t OH_RDB_GetChangedCount(OH_RDB_ReturningContext *context) | Obtains the number of data rows affected by the operation. |
Enum Description
Rdb_ConflictResolution
enum Rdb_ConflictResolution
Description
Enumerates the conflict resolution policies.
Since: 18
| Enum Item | Description |
|---|---|
| RDB_CONFLICT_NONE = 1 | No operation is performed when a conflict occurs. |
| RDB_CONFLICT_ROLLBACK | Throws an error and rolls back the transaction. |
| RDB_CONFLICT_ABORT | Throws an error and rolls back the current change. |
| RDB_CONFLICT_FAIL | Throws an error and aborts the current change without rolling back the modifications before the conflict. |
| RDB_CONFLICT_IGNORE | Ignores the conflicted data and resolves the conflict later. |
| RDB_CONFLICT_REPLACE | Deletes the data and then inserts the data. If the conflict persists, applies RDB_CONFLICT_ABORT. |
Function Description
OH_RDB_CreateReturningContext()
OH_RDB_ReturningContext *OH_RDB_CreateReturningContext(void)
Description
Creates an OH_RDB_ReturningContext instance.
Since: 23
Returns
| Type | Description |
|---|---|
| OH_RDB_ReturningContext * | Returns a pointer to the OH_RDB_ReturningContext instance if the operation is successful; returns nullptr otherwise. You must release the memory via the [OH_RDB_DestroyReturningContext](capi-oh-rdb-types-h.md#oh_rdb_destroyreturningcontext API after use. |
OH_RDB_DestroyReturningContext()
void OH_RDB_DestroyReturningContext(OH_RDB_ReturningContext *context)
Description
Destroys an OH_RDB_ReturningContext instance.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_RDB_ReturningContext *context | Pointer to the OH_RDB_ReturningContext instance. |
OH_RDB_SetReturningFields()
int OH_RDB_SetReturningFields(OH_RDB_ReturningContext *context, const char *const fields[], int32_t len)
Description
Sets the fields returned in the result set.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_RDB_ReturningContext *context | Pointer to the OH_RDB_ReturningContext instance. |
| const char *const fields[] | Names of the columns to be returned. |
| int32_t len | Field length. |
Returns
| Type | Description |
|---|---|
| int | Check result. Returns RDB_OK if the operation is successful; returns RDB_E_INVALID_ARGS if the input parameters are invalid. |
OH_RDB_SetMaxReturningCount()
int OH_RDB_SetMaxReturningCount(OH_RDB_ReturningContext *context, int32_t count)
Description
Sets the maximum number of rows for the returned result set.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_RDB_ReturningContext *context | Pointer to the OH_RDB_ReturningContext instance. |
| int32_t count | Maximum number of rows for the returned result set. |
Returns
| Type | Description |
|---|---|
| int | Check result. Returns RDB_OK if the operation is successful; returns RDB_E_INVALID_ARGS if the input parameters are invalid. |
OH_RDB_GetReturningValues()
OH_Cursor *OH_RDB_GetReturningValues(OH_RDB_ReturningContext *context)
Description
Obtains the cursor of data changes, which contains 1,024 rows by default.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_RDB_ReturningContext *context | Pointer to the OH_RDB_ReturningContext instance. |
Returns
| Type | Description |
|---|---|
| OH_Cursor * | Returns a pointer to the OH_Cursor instance if the operation is successful; returns nullptr otherwise. The cursor is destroyed when the OH_RDB_DestroyReturningContext API is called to release memory, and no separate release is required for the cursor. |
OH_RDB_GetChangedCount()
int64_t OH_RDB_GetChangedCount(OH_RDB_ReturningContext *context)
Description
Obtains the number of data rows affected by the operation.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_RDB_ReturningContext *context | Pointer to the OH_RDB_ReturningContext instance. |
Returns
| Type | Description |
|---|---|
| int64_t | Returns the number of changed data rows. If the changed rows fail to be obtained, -1 is returned. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 js-apis-distributedKVStore-sys
openharmony 鸿蒙 capi-oh-preferences-h
openharmony 鸿蒙 capi-udmf-oh-udshyperlink
openharmony 鸿蒙 js-apis-data-dataSharePredicates
openharmony 鸿蒙 capi-udmf-oh-udsappitem
openharmony 鸿蒙 capi-rdb-oh-data-vbuckets
openharmony 鸿蒙 capi-rdb-oh-predicates
openharmony 鸿蒙 capi-rdb-oh-data-value