openharmony 鸿蒙 capi-oh-rdb-types-h

2026-08-25 浏览 (1)

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

Nametypedef KeywordDescription
OH_RDB_ReturningContextOH_RDB_ReturningContextContext of the returning-related APIs.

Enums

Nametypedef KeywordDescription
Rdb_ConflictResolutionRdb_ConflictResolutionEnumerates the conflict resolution policies.

Functions

NameDescription
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 ItemDescription
RDB_CONFLICT_NONE = 1No operation is performed when a conflict occurs.
RDB_CONFLICT_ROLLBACKThrows an error and rolls back the transaction.
RDB_CONFLICT_ABORTThrows an error and rolls back the current change.
RDB_CONFLICT_FAILThrows an error and aborts the current change without rolling back the modifications before the conflict.
RDB_CONFLICT_IGNOREIgnores the conflicted data and resolves the conflict later.
RDB_CONFLICT_REPLACEDeletes 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

TypeDescription
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

NameDescription
OH_RDB_ReturningContext *contextPointer 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

NameDescription
OH_RDB_ReturningContext *contextPointer to the OH_RDB_ReturningContext instance.
const char *const fields[]Names of the columns to be returned.
int32_t lenField length.

Returns

TypeDescription
intCheck 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

NameDescription
OH_RDB_ReturningContext *contextPointer to the OH_RDB_ReturningContext instance.
int32_t countMaximum number of rows for the returned result set.

Returns

TypeDescription
intCheck 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

NameDescription
OH_RDB_ReturningContext *contextPointer to the OH_RDB_ReturningContext instance.

Returns

TypeDescription
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

NameDescription
OH_RDB_ReturningContext *contextPointer to the OH_RDB_ReturningContext instance.

Returns

TypeDescription
int64_tReturns 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

openharmony 鸿蒙 capi-preferences-oh-preferencespair

openharmony 鸿蒙 errorcode-datashare

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/CGhE2cpO