relational_store.h
Overview
Provides APIs for managing data in an RDB store. The APIs not marked as supporting vector stores are available only to RDB stores.
File to include: <database/rdb/relational_store.h>
Library: libnative_rdb_ndk.z.so
System capability: SystemCapability.DistributedDataManager.RelationalStore.Core
Since: 10
Related module: RDB
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| OH_Rdb_Config | OH_Rdb_Config | Defines the configuration of an RDB store. |
| OH_Rdb_Store | OH_Rdb_Store | Defines the RDB store type. |
| Rdb_DistributedConfig | Rdb_DistributedConfig | Defines a struct for distributed configuration of a table. |
| Rdb_KeyInfo | Rdb_KeyInfo | Defines a struct for the primary key or number of the row that changes. |
| Rdb_KeyData | - | Stores the changed data. |
| Rdb_ChangeInfo | Rdb_ChangeInfo | Defines a struct for the details about the device-cloud sync process. |
| Rdb_SubscribeCallback | Rdb_SubscribeCallback | Defines a callback used to return the subscribed event. |
| Rdb_DataObserver | Rdb_DataObserver | Defines a struct for the data observer. |
| Rdb_Statistic | Rdb_Statistic | Defines a struct for the device-cloud sync statistics of a database table. |
| Rdb_TableDetails | Rdb_TableDetails | Defines a struct for statistics of device-cloud upload and download tasks of a database table. |
| Rdb_ProgressDetails | Rdb_ProgressDetails | Defines a struct for statistics of the overall device-cloud sync (upload and download) tasks of an RDB store. |
| Rdb_ProgressObserver | Rdb_ProgressObserver | Defines the observer of the device-cloud sync progress. |
| OH_Rdb_ConfigV2 | OH_Rdb_ConfigV2 | Defines a struct for the RDB store configuration. Different from OH_Rdb_Config, this struct does not expose its member variables externally. Methods are used to configure the properties of this struct. It supports vector stores. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| OH_Rdb_SecurityLevel | OH_Rdb_SecurityLevel | Enumerates the RDB store security levels. |
| Rdb_SecurityArea | Rdb_SecurityArea | Enumerates the encryption levels of database files. |
| Rdb_DBType | Rdb_DBType | Enumerates the database kernel types. |
| Rdb_Tokenizer | Rdb_Tokenizer | Enumerates the database tokenizer types. |
| Rdb_DistributedType | Rdb_DistributedType | Enumerates the distributed types. |
| Rdb_ChangeType | Rdb_ChangeType | Enumerates the data change types. |
| Rdb_SubscribeType | Rdb_SubscribeType | Enumerates the subscription types. |
| Rdb_SyncMode | Rdb_SyncMode | Enumerates the RDB sync modes. |
| Rdb_Progress | Rdb_Progress | Enumerates the device-cloud sync progress states. |
| Rdb_ProgressCode | Rdb_ProgressCode | Enumerates the device-cloud sync states. |
Functions
Macros
| Name | Description |
|---|---|
| DISTRIBUTED_CONFIG_VERSION 1 | Describes the version of Rdb_DistributedConfig. Since: 11 |
| DISTRIBUTED_CHANGE_INFO_VERSION 1 | Describes the version of Rdb_ChangeInfo. Since: 11 |
| DISTRIBUTED_PROGRESS_DETAIL_VERSION 1 | Describes the version of Rdb_ProgressDetails. Since: 11 |
Enum Description
OH_Rdb_SecurityLevel
enum OH_Rdb_SecurityLevel
Description
Enumerates the RDB store security levels.
Since: 10
| Enum Item | Description |
|---|---|
| S1 = 1 | Low security level. If data leakage occurs, minor impact will be caused. |
| S2 | Medium security level. If data leakage occurs, moderate impact will be caused. |
| S3 | High security level. If data leakage occurs, major impact will be caused. |
| S4 | Critical security level. If data leakage occurs, critical impact will be caused. |
Rdb_SecurityArea
enum Rdb_SecurityArea
Description
Enumerates the encryption levels of database files.
Since: 11
| Enum Item | Description |
|---|---|
| RDB_SECURITY_AREA_EL1 = 1 | Encryption level 1. |
| RDB_SECURITY_AREA_EL2 | Encryption level 2. |
| RDB_SECURITY_AREA_EL3 | Encryption level 3. |
| RDB_SECURITY_AREA_EL4 | Encryption level 4. |
| RDB_SECURITY_AREA_EL5 | Encryption level 5. Since: 12 |
Rdb_DBType
enum Rdb_DBType
Description
Enumerates the database kernel types.
Since: 14
| Enum Item | Description |
|---|---|
| RDB_SQLITE = 1 | SQLite is used as the database kernel. |
| RDB_CAYLEY = 2 | Cayley is used as the database kernel. |
| DBTYPE_BUTT = 64 | Maximum value of the database kernel type, which is an invalid value. |
Rdb_Tokenizer
enum Rdb_Tokenizer
Description
Enumerates the database tokenizer types.
Since: 17
| Enum Item | Description |
|---|---|
| RDB_NONE_TOKENIZER = 1 | No tokenizer is used. |
| RDB_ICU_TOKENIZER = 2 | ICU tokenizer. |
| RDB_CUSTOM_TOKENIZER = 3 | Custom tokenizer. Since: 18 |
Rdb_DistributedType
enum Rdb_DistributedType
Description
Enumerates the distributed types.
Since: 11
| Enum Item | Description |
|---|---|
| RDB_DISTRIBUTED_CLOUD | Distributed database tables for device-cloud sync. |
Rdb_ChangeType
enum Rdb_ChangeType
Description
Enumerates the data change types.
Since: 11
| Enum Item | Description |
|---|---|
| RDB_DATA_CHANGE | Data change. |
| RDB_ASSET_CHANGE | Asset change. |
Rdb_SubscribeType
enum Rdb_SubscribeType
Description
Enumerates the subscription types.
Since: 11
| Enum Item | Description |
|---|---|
| RDB_SUBSCRIBE_TYPE_CLOUD | Subscribe to cloud data changes. |
| RDB_SUBSCRIBE_TYPE_CLOUD_DETAILS | Subscribe to detailed information about cloud data changes. |
| RDB_SUBSCRIBE_TYPE_LOCAL_DETAILS | Subscribe to detailed information about local data changes. Since: 12 |
Rdb_SyncMode
enum Rdb_SyncMode
Description
Sync mode of the database.
Since: 11
| Enum Item | Description |
|---|---|
| RDB_SYNC_MODE_TIME_FIRST | Synchronize with the data with the latest modification time. |
| RDB_SYNC_MODE_NATIVE_FIRST | Synchronize data from a local device to the cloud. |
| RDB_SYNC_MODE_CLOUD_FIRST | Synchronize data from the cloud to a local device. |
Rdb_Progress
enum Rdb_Progress
Description
Enumerates the device-cloud sync progress states.
Since: 11
| Enum Item | Description |
|---|---|
| RDB_SYNC_BEGIN | The device-cloud sync starts. |
| RDB_SYNC_IN_PROGRESS | The device-cloud sync is in progress. |
| RDB_SYNC_FINISH | The device-cloud sync is finished. |
Rdb_ProgressCode
enum Rdb_ProgressCode
Description
Enumerates the device-cloud sync states.
Since: 11
| Enum Item | Description |
|---|---|
| RDB_SUCCESS | The device-cloud sync is successful. |
| RDB_UNKNOWN_ERROR | An unknown error occurs during the device-cloud sync. |
| RDB_NETWORK_ERROR | A network error occurs during the device-cloud sync. |
| RDB_CLOUD_DISABLED | The cloud is unavailable. |
| RDB_LOCKED_BY_OTHERS | The device-cloud sync of another device is being performed. |
| RDB_RECORD_LIMIT_EXCEEDED | The number of records or size of the data to be synced exceeds the maximum. The maximum value is configured on the cloud. |
| RDB_NO_SPACE_FOR_ASSET | The remaining cloud space is less than the size of the data to be synced. |
Function Description
OH_Rdb_SetSemanticIndex()
int OH_Rdb_SetSemanticIndex(OH_Rdb_ConfigV2 *config, bool enableSemanticIndex)
Description
Sets whether to enable knowledge processing based on semantic indexes.
Since: 20
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance. |
| bool enableSemanticIndex | Whether to enable knowledge processing based on semantic indexes. The value true indicates that the function is enabled; the value false indicates the opposite. |
Returns
| Type | Description |
|---|---|
| int | Returns an error code. For details about the error codes, see OH_Rdb_ErrCode. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_CreateConfig()
OH_Rdb_ConfigV2 *OH_Rdb_CreateConfig()
Description
Creates an OH_Rdb_ConfigV2 instance.
Since: 14
Returns
| Type | Description |
|---|---|
| OH_Rdb_ConfigV2 | Pointer to the OH_Rdb_ConfigV2 instance. After use, release the memory by calling the OH_Rdb_DestroyConfig API. |
See
OH_Rdb_ConfigV2
OH_Rdb_DestroyConfig()
int OH_Rdb_DestroyConfig(OH_Rdb_ConfigV2 *config)
Description
Destroys an OH_Rdb_ConfigV2 instance created by OH_Rdb_CreateConfig.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetDatabaseDir()
int OH_Rdb_SetDatabaseDir(OH_Rdb_ConfigV2 *config, const char *databaseDir)
Description
Sets the database file path for an OH_Rdb_ConfigV2 instance.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| const char *dataBaseDir | Pointer to the database file path to set. The full path, including the RDB store name, cannot exceed a maximum of 1024 characters. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetStoreName()
int OH_Rdb_SetStoreName(OH_Rdb_ConfigV2 *config, const char *storeName)
Description
Sets the database name for an OH_Rdb_ConfigV2 instance.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| const char *storeName | Pointer to the RDB store name to set. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetBundleName()
int OH_Rdb_SetBundleName(OH_Rdb_ConfigV2 *config, const char *bundleName)
Description
Sets the bundle name for an OH_Rdb_ConfigV2 instance.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| const char *bundleName | Pointer to the application bundle name to set. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetModuleName()
int OH_Rdb_SetModuleName(OH_Rdb_ConfigV2 *config, const char *moduleName)
Description
Sets the module name for an OH_Rdb_ConfigV2 instance.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| const char *moduleName | Pointer to the module name to set. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetEncrypted()
int OH_Rdb_SetEncrypted(OH_Rdb_ConfigV2 *config, bool isEncrypted)
Description
Sets whether to encrypt the database for an OH_Rdb_ConfigV2 instance.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| bool isEncrypted | Whether to encrypt the RDB store. The value true means to encrypt the database; the value false means the opposite. After the database is created, this parameter cannot be modified directly. To change the database encryption status, call the OH_Rdb_RekeyEx API. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetSecurityLevel()
int OH_Rdb_SetSecurityLevel(OH_Rdb_ConfigV2 *config, int securityLevel)
Description
Sets the database security level (OH_Rdb_SecurityLevel) for an OH_Rdb_ConfigV2 instance.
This method must be called during database creation. Otherwise, the database file cannot be created, and the error code RDB_E_INVALID_ARGS is returned when the OH_Rdb_CreateOrOpen API is called.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| int securityLevel | Database security level (OH_Rdb_SecurityLevel). |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetArea()
int OH_Rdb_SetArea(OH_Rdb_ConfigV2 *config, int area)
Description
Sets the security area level (Rdb_SecurityArea) for an OH_Rdb_ConfigV2 instance.
This method must be called during database creation. Otherwise, the database file cannot be created, and the error code RDB_E_INVALID_ARGS is returned when the OH_Rdb_CreateOrOpen API is called.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| int area | Database security area level (Rdb_SecurityArea). |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetDbType()
int OH_Rdb_SetDbType(OH_Rdb_ConfigV2 *config, int dbType)
Description
Sets the database type (Rdb_DBType) for an OH_Rdb_ConfigV2 instance.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| int dbType | Database type (Rdb_DBType). |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_NOT_SUPPORTED indicates that the current operation is not supported. |
OH_Rdb_SetCustomDir()
int OH_Rdb_SetCustomDir(OH_Rdb_ConfigV2 *config, const char *customDir)
Description
Sets the custom directory of the database.
Since: 20
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance. |
| const char *customDir | Custom directory of the database, with a maximum length of 128 bytes. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetReadOnly()
int OH_Rdb_SetReadOnly(OH_Rdb_ConfigV2 *config, bool readOnly)
Description
Sets whether the RDB store is in read-only mode.
Since: 20
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance. |
| bool readOnly | Whether the RDB store is in read-only mode. The value true indicates that the RDB store is in read-only mode; the value false indicates that the RDB store is in read/write mode. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetPlugins()
int OH_Rdb_SetPlugins(OH_Rdb_ConfigV2 *config, const char **plugins, int32_t length)
Description
Sets the dynamic library with specific capabilities (such as full-text search).
Since: 20
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance. |
| const char **plugins | Name array of the dynamic library. |
| int32_t length | Size of the plugin array. The maximum value is 16. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetCryptoParam()
int OH_Rdb_SetCryptoParam(OH_Rdb_ConfigV2 *config, const OH_Rdb_CryptoParam *cryptoParam)
Description
Sets custom encryption parameters.
Since: 20
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance. |
| const OH_Rdb_CryptoParam *cryptoParam | Custom encryption parameters. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_IsTokenizerSupported()
int OH_Rdb_IsTokenizerSupported(Rdb_Tokenizer tokenizer, bool *isSupported)
Description
Checks whether the specified tokenizer is supported.
Since: 18
Parameters
| Parameter | Description |
|---|---|
| Rdb_Tokenizer tokenizer | Tokenizer to check. |
| bool *isSupported | Pointer to the check result. The value true means the tokenizer is supported; the value false means the opposite. |
Returns
| Type | Description |
|---|---|
| int | Returns operation status code. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetTokenizer()
int OH_Rdb_SetTokenizer(OH_Rdb_ConfigV2 *config, Rdb_Tokenizer tokenizer)
Description
Sets the tokenizer type.
Since: 17
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the database configuration related to the RDB storage. |
| Rdb_Tokenizer tokenizer | Tokenizer type to set. |
Returns
| Type | Description |
|---|---|
| int | Returns operation status code. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_NOT_SUPPORTED indicates that the current operation is not supported. |
OH_Rdb_SetPersistent()
int OH_Rdb_SetPersistent(OH_Rdb_ConfigV2 *config, bool isPersistent)
Description
Sets whether to persist an RDB store.
Since: 18
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which specifies the database configuration. |
| bool isPersistent | Whether to persist the database data. |
Returns
| Type | Description |
|---|---|
| int | Returns operation status code. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_GetSupportedDbType()
const int *OH_Rdb_GetSupportedDbType(int *typeCount)
Description
Obtains the supported database type (Rdb_DBType).
Since: 14
Parameters
| Parameter | Description |
|---|---|
| int *typeCount | Pointer to the length of the array of the supported database types obtained. |
Returns
| Type | Description |
|---|---|
| const int * | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_CreateValueObject()
OH_VObject *OH_Rdb_CreateValueObject()
Description
Creates an OH_VObject instance.
Since: 10
Returns
| Type | Description |
|---|---|
| OH_VObject | Returns the pointer to the OH_VObject instance created if the operation is successful; returns NULL otherwise. |
See
OH_VObject
OH_Rdb_CreateValuesBucket()
OH_VBucket *OH_Rdb_CreateValuesBucket()
Description
Creates an OH_VBucket instance.
Since: 10
Returns
| Type | Description |
|---|---|
| OH_VBucket | Returns the pointer to the OH_VBucket instance created if the operation is successful; returns NULL otherwise. |
See
OH_VBucket
OH_Rdb_CreatePredicates()
OH_Predicates *OH_Rdb_CreatePredicates(const char *table)
Description
Creates an OH_Predicates instance.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| const char *table | Pointer to the name of the database table. |
Returns
| Type | Description |
|---|---|
| OH_Predicates | Returns the pointer to the OH_Predicates instance created if the operation is successful; returns NULL otherwise. |
See
OH_Predicates
OH_Rdb_GetOrOpen()
OH_Rdb_Store *OH_Rdb_GetOrOpen(const OH_Rdb_Config *config, int *errCode)
Description
Obtains a related OH_Rdb_Store instance to operate the RDB store.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| const OH_Rdb_Config *config | Pointer to the OH_Rdb_Config instance, which is the configuration of the RDB store. |
| int *errCode | Pointer to the execution result of this API. |
Returns
| Type | Description |
|---|---|
| OH_Rdb_Store | Returns the pointer to the OH_Rdb_Store instance created if the operation is successful; returns NULL otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_CreateOrOpen()
OH_Rdb_Store *OH_Rdb_CreateOrOpen(const OH_Rdb_ConfigV2 *config, int *errCode)
Description
Creates or opens an OH_Rdb_Store instance based on the given OH_Rdb_ConfigV2.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| const OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| int *errCode | Pointer to the execution result of this API. |
Returns
| Type | Description |
|---|---|
| OH_Rdb_Store | Returns the pointer to the OH_Rdb_Store instance created if the operation is successful; returns NULL otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_CloseStore()
int OH_Rdb_CloseStore(OH_Rdb_Store *store)
Description
Closes an OH_Rdb_Store object and reclaims the memory occupied by the object.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_DeleteStore()
int OH_Rdb_DeleteStore(const OH_Rdb_Config *config)
Description
Deletes an RDB store with the specified configuration.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| const OH_Rdb_Config *config | Pointer to the database configuration. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_DeleteStoreV2()
int OH_Rdb_DeleteStoreV2(const OH_Rdb_ConfigV2 *config)
Description
Deletes an RDB store based on the given OH_Rdb_ConfigV2.
Before calling DeleteStoreV2, ensure that the OH_Rdb_Store and OH_Cursor of the vector store have been closed.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| const OH_Rdb_ConfigV2 *config | Pointer to the database configuration. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_Insert()
int OH_Rdb_Insert(OH_Rdb_Store *store, const char *table, OH_VBucket *valuesBucket)
Description
Inserts a row of data into a table.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *table | Pointer to the target table. |
| OH_VBucket *valuesBucket | Pointer to the data OH_VBucket to insert. |
Returns
| Type | Description |
|---|---|
| int | Returns rowID if the operation is successful; returns a number less than 0 otherwise. RDB_ERR indicates that the operation fails. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_InsertWithConflictResolution()
int OH_Rdb_InsertWithConflictResolution(OH_Rdb_Store *store, const char *table, OH_VBucket *row,Rdb_ConflictResolution resolution, int64_t *rowId)
Description
Inserts a row of data into the target table and supports conflict resolution.
Since: 20
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *table | Name of the target table. |
| OH_VBucket *row | Pointer to the row of data to insert. |
| Rdb_ConflictResolution resolution | Policy used to resolve file conflicts. |
| int64_t *rowId | Pointer to the row number returned. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_ERROR indicates a common database error. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_ALREADY_CLOSED indicates that the database is already closed. RDB_E_WAL_SIZE_OVER_LIMIT indicates that the size of the WAL log file exceeds the default value. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_PERM indicates an SQLite error: access denied. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_LOCKED indicates an SQLite error: database table locked. RDB_E_SQLITE_NOMEM indicates an SQLite: insufficient database memory. RDB_E_SQLITE_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite: disk I/O error. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_CONSTRAINT indicates an SQLite error code: SQLite constraint. |
OH_Rdb_BatchInsert()
int OH_Rdb_BatchInsert(OH_Rdb_Store *store, const char *table,const OH_Data_VBuckets *rows, Rdb_ConflictResolution resolution, int64_t *changes)
Description
Inserts data into a table in batches.
A maximum of 32,766 parameters can be inserted at a time. If the number of parameters exceeds this limit, the error code RDB_E_INVALID_ARGS is returned. The number of inserted data records multiplied by the size of the union set of all fields in the inserted data equals the number of parameters.
For example, if the size of the union set is 10, a maximum of 3,276 data records can be inserted (3276 × 10 = 32760).
Ensure that you comply with this constraint when calling this API to avoid errors caused by excessive parameters.
Since: 18
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *tables | Pointer to the names of the distributed tables to set. |
| const OH_Data_VBuckets *rows | An array of data to insert. |
| Rdb_ConflictResolution resolution | Policy used to resolve file conflicts. |
| int64_t *changes | Pointer to the number of successful insertions. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_ERROR indicates a common database error. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_ALREADY_CLOSED indicates that the database is already closed. RDB_E_WAL_SIZE_OVER_LIMIT indicates that the size of the WAL log file exceeds the default value. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_PERM indicates an SQLite error: access denied. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_LOCKED indicates an SQLite error: database table locked. RDB_E_SQLITE_NOMEM indicates an SQLite: insufficient database memory. RDB_E_SQLITE_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite: disk I/O error. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_CONSTRAINT indicates an SQLite error code: SQLite constraint. |
OH_Rdb_Update()
int OH_Rdb_Update(OH_Rdb_Store *store, OH_VBucket *valuesBucket, OH_Predicates *predicates)
Description
Updates data in an RDB store based on specified conditions.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_VBucket *valuesBucket | Pointer to the data OH_VBucket to update. |
| OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the update conditions. |
Returns
| Type | Description |
|---|---|
| int | Returns the number of updated rows if the operation is successful; returns a number less than 0 otherwise. RDB_ERR indicates that the operation fails. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_UpdateWithConflictResolution()
int OH_Rdb_UpdateWithConflictResolution(OH_Rdb_Store *store, OH_VBucket *row, OH_Predicates *predicates,Rdb_ConflictResolution resolution, int64_t *changes)
Description
Updates data in the database based on specified conditions and supports conflict resolution.
Since: 20
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_VBucket *row | Pointer to the row of data to update. |
| OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the update conditions. |
| Rdb_ConflictResolution resolution | Policy used to resolve file conflicts. |
| int64_t *changes | Pointer to the number of rows that are successfully updated. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_ERROR indicates a common database error. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_ALREADY_CLOSED indicates that the database is already closed. RDB_E_WAL_SIZE_OVER_LIMIT indicates that the size of the WAL log file exceeds the default value. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_PERM indicates an SQLite error: access denied. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_LOCKED indicates an SQLite error: database table locked. RDB_E_SQLITE_NOMEM indicates an SQLite: insufficient database memory. RDB_E_SQLITE_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite: disk I/O error. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_CONSTRAINT indicates an SQLite error code: SQLite constraint. |
OH_Rdb_Delete()
int OH_Rdb_Delete(OH_Rdb_Store *store, OH_Predicates *predicates)
Description
Deletes data from an RDB store based on specified conditions.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the deletion conditions. |
Returns
| Type | Description |
|---|---|
| int | Returns the number of deleted rows if the operation is successful; returns a number less than 0 otherwise. RDB_ERR indicates that the operation fails. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_Query()
OH_Cursor *OH_Rdb_Query(OH_Rdb_Store *store, OH_Predicates *predicates, const char *const *columnNames, int length)
Description
Queries data in an RDB store based on specified conditions.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the query conditions. |
| const char *const *columnNames | Columns to query. If null is passed in, all columns are queried. |
| int length | Length of columnNames. If the length is greater than the length of columnNames array, an out-of-bounds access will occur. |
Returns
| Type | Description |
|---|---|
| OH_Cursor * | Returns the pointer to the OH_Cursor instance if the operation is successful; returns NULL otherwise. |
OH_Rdb_Execute()
int OH_Rdb_Execute(OH_Rdb_Store *store, const char *sql)
Description
Executes an SQL statement that returns no value.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *sql | SQL statement to execute. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
See
OH_Rdb_Store
OH_Rdb_ExecuteV2()
int OH_Rdb_ExecuteV2(OH_Rdb_Store *store, const char *sql, const OH_Data_Values *args, OH_Data_Value **result)
Description
Executes an SQL statement with a return value. This API supports vector stores.
Statements starting with comments are not supported.
Since: 18
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *sql | SQL statement to execute. |
| const OH_Data_Values *args | (Optional) Pointer to the OH_Data_Values instance. |
| OH_Data_Value **result | Pointer to the OH_Data_Value instance when the execution is successful. Use OH_Value_Destroy to release the memory in time. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_ERROR indicates a common database error. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_ALREADY_CLOSED indicates that the database is already closed. RDB_E_WAL_SIZE_OVER_LIMIT indicates that the size of the WAL log file exceeds the default value. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_PERM indicates an SQLite error: access denied. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_LOCKED indicates an SQLite error: database table locked. RDB_E_SQLITE_NOMEM indicates an SQLite: insufficient database memory. RDB_E_SQLITE_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite: disk I/O error. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. |
See
OH_Value_Destroy
OH_Rdb_ExecuteByTrxId()
int OH_Rdb_ExecuteByTrxId(OH_Rdb_Store *store, int64_t trxId, const char *sql)
Description
Executes an SQL statement that returns no value based on the specified transaction ID. This API supports only vector stores.
Statements starting with comments are not supported.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| int64_t trxId | Transaction ID returned by OH_Rdb_BeginTransWithTrxId. The value 0 indicates that no transaction is enabled. |
| const char *sql | SQL statement to execute. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates invalid parameters. The possible causes are as follows: The input parameter is a null pointer. The current transaction ID is not obtained by calling OH_Rdb_BeginTransWithTrxId. The current transaction ID has been submitted by calling OH_Rdb_CommitByTrxId. The current transaction ID has been rolled back by calling OH_Rdb_RollBackByTrxId. store or sql is NULL. RDB_E_NOT_SUPPORTED indicates that the current operation is not supported. |
See
OH_Rdb_Store
OH_Rdb_ExecuteQuery()
OH_Cursor *OH_Rdb_ExecuteQuery(OH_Rdb_Store *store, const char *sql)
Description
Queries data in the database using the specified SQL statement. This API supports vector stores.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *sql | SQL statement to execute. |
Returns
| Type | Description |
|---|---|
| OH_Cursor | Returns the pointer to the OH_Cursor instance if the operation is successful; returns NULL otherwise. |
See
OH_Rdb_Store
OH_Rdb_ExecuteQueryV2()
OH_Cursor *OH_Rdb_ExecuteQueryV2(OH_Rdb_Store *store, const char *sql, const OH_Data_Values *args)
Description
Queries data in the database using the specified SQL statement. This API supports vector stores.
Since: 18
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *sql | SQL statement to execute. |
| const OH_Data_Values *args | (Optional) Pointer to the OH_Data_Values instance. |
Returns
| Type | Description |
|---|---|
| OH_Cursor * | Returns a pointer to the OH_Cursor instance if the operation is successful. The OH_Cursor instance is released if it is no longer required in time. Returns NULL if the SQL statement is invalid or the memory allocation fails. |
See
OH_Rdb_Store
OH_Rdb_BeginTransaction()
int OH_Rdb_BeginTransaction(OH_Rdb_Store *store)
Description
Begins the transaction before executing SQL statements.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_RollBack()
int OH_Rdb_RollBack(OH_Rdb_Store *store)
Description
Rolls back the SQL statements executed.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_Commit()
int OH_Rdb_Commit(OH_Rdb_Store *store)
Description
Commits the executed SQL statement.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_BeginTransWithTrxId()
int OH_Rdb_BeginTransWithTrxId(OH_Rdb_Store *store, int64_t *trxId)
Description
Begins a transaction. This API returns a transaction ID and supports only vector stores.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| int64_t *trxId | Pointer to the transaction ID returned. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_NOT_SUPPORTED indicates that the current operation is not supported. |
OH_Rdb_RollBackByTrxId()
int OH_Rdb_RollBackByTrxId(OH_Rdb_Store *store, int64_t trxId)
Description
Rolls back the executed SQL statements based on the specified transaction ID. This API supports only vector stores.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| int64_t trxId | ID of the transaction to be rolled back. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates invalid parameters. The possible causes are as follows: The input parameter is a null pointer. The current transaction ID is not obtained by calling OH_Rdb_BeginTransWithTrxId. The current transaction ID has been submitted by calling OH_Rdb_CommitByTrxId. The current transaction ID has been rolled back by calling OH_Rdb_RollBackByTrxId. RDB_E_NOT_SUPPORTED indicates that the current operation is not supported. |
OH_Rdb_CommitByTrxId()
int OH_Rdb_CommitByTrxId(OH_Rdb_Store *store, int64_t trxId)
Description
Commits the executed SQL statements based on the specified transaction ID. This API supports only vector stores.
Since: 14
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| int64_t trxId | Transaction ID. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates invalid parameters. The possible causes are as follows: The input parameter is a null pointer. The current transaction ID is not obtained by calling OH_Rdb_BeginTransWithTrxId. The current transaction ID has been submitted by calling OH_Rdb_CommitByTrxId. The current transaction ID has been rolled back by calling OH_Rdb_RollBackByTrxId. RDB_E_NOT_SUPPORTED indicates that the current operation is not supported. |
See
OH_Rdb_Store
OH_Rdb_Backup()
int OH_Rdb_Backup(OH_Rdb_Store *store, const char *databasePath)
Description
Backs up an RDB store using the backup file of the specified path. This API supports vector stores.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *databasePath | Pointer to the destination directory in which the RDB store is backed up. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
See
OH_Rdb_Store
OH_Rdb_Restore()
int OH_Rdb_Restore(OH_Rdb_Store *store, const char *databasePath)
Description
Restores a database from a specified database backup file. This API supports vector stores.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *databasePath | Pointer to the destination directory in which the RDB store is backed up. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_GetVersion()
int OH_Rdb_GetVersion(OH_Rdb_Store *store, int *version)
Description
Obtains the RDB store version.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| int *version | Pointer to the version number. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SetVersion()
int OH_Rdb_SetVersion(OH_Rdb_Store *store, int version)
Description
Sets the RDB store version.
Since: 10
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| int version | Version to set. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
See
OH_Rdb_Store
OH_Rdb_SetDistributedTables()
int OH_Rdb_SetDistributedTables(OH_Rdb_Store *store, const char *tables[], uint32_t count, Rdb_DistributedType type,const Rdb_DistributedConfig *config)
Description
Sets distributed database tables.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *tables[] | Pointer to the names of the distributed tables to set. |
| uint32_t count | Number of distributed database tables to be set. |
| Rdb_DistributedType type | Rdb_DistributedType of the table. |
| const Rdb_DistributedConfig *config | Pointer to the distributed configuration of a table (Rdb_DistributedConfig). |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
See
OH_Rdb_Store
OH_Rdb_FindModifyTime()
OH_Cursor *OH_Rdb_FindModifyTime(OH_Rdb_Store *store, const char *tableName, const char *columnName,OH_VObject *values)
Description
Obtains the last modification time of a table in an RDB store.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *tableName | Pointer to the target distributed database table name. |
| const char *columnName | Pointer to the column name of the database table to query. |
| OH_VObject *values | Pointer to the primary keys of the rows to query. If the database table has no primary key, rowid must be passed in through columnName. In this case, values specifies the row number of the database table to query. |
Returns
| Type | Description |
|---|---|
| OH_Cursor | Returns the pointer to the OH_Rdb_Store instance created if the operation is successful; returns NULL otherwise. |
Rdb_BriefObserver()
typedef void (*Rdb_BriefObserver)(void *context, const char *values[], uint32_t count)
Description
Callback used to return the device-cloud data change event.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| void *context | Pointer to the context of the data observer. |
| const char *values[] | Pointer to the accounts whose device-cloud data is changed. |
| uint32_t count | Number of accounts whose device-cloud data is changed. |
Rdb_DetailsObserver()
typedef void (*Rdb_DetailsObserver)(void *context, const Rdb_ChangeInfo **changeInfo, uint32_t count)
Description
Callback used to return the details about the device-cloud data change.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| void *context | Pointer to the context of the data observer. |
| const Rdb_ChangeInfo **changeInfo | Information about the changed table (Rdb_ChangeInfo). |
| uint32_t count | Number of changed tables. |
OH_Rdb_Subscribe()
int OH_Rdb_Subscribe(OH_Rdb_Store *store, Rdb_SubscribeType type, const Rdb_DataObserver *observer)
Description
Registers an observer for an RDB store. The registered callback will be invoked when data in a distributed or local RDB store changes.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| Rdb_SubscribeType type | Subscription type (Rdb_SubscribeType). If the value is RDB_SUBSCRIBE_TYPE_LOCAL_DETAILS, the callback is called when the data in the local RDB store changes. |
| const Rdb_DataObserver *observer | Pointer to the Rdb_DataObserver instance. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_Unsubscribe()
int OH_Rdb_Unsubscribe(OH_Rdb_Store *store, Rdb_SubscribeType type, const Rdb_DataObserver *observer)
Description
Unregisters the observer of the specified type.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| Rdb_SubscribeType type | Subscription type (Rdb_SubscribeType). |
| const Rdb_DataObserver *observer | Pointer to the Rdb_DataObserver instance. If this parameter is nullptr, all observers of this type will be unregistered. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_GetTableDetails()
Rdb_TableDetails *OH_Rdb_GetTableDetails(Rdb_ProgressDetails *progress, int32_t version)
Description
Obtains the device-cloud sync statistics of a table.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| Rdb_ProgressDetails *progress | Pointer to the Rdb_ProgressDetails instance. |
| int32_t version | Version of the current Rdb_ProgressDetails. |
Returns
| Type | Description |
|---|---|
| Rdb_TableDetails | Returns a pointer to Rdb_TableDetails if the operation is successful; returns NULL otherwise. |
See
Rdb_TableDetails
Rdb_ProgressCallback()
typedef void (*Rdb_ProgressCallback)(void *context, Rdb_ProgressDetails *progressDetails)
Description
Defines a callback used to return the device-cloud sync progress.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| void *context | Pointer to the context of the callback data. |
| Rdb_ProgressDetails *progressDetails | Details about the device-cloud sync progress. |
Rdb_SyncCallback()
typedef void (*Rdb_SyncCallback)(Rdb_ProgressDetails *progressDetails)
Description
Defines a callback for device-cloud sync.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| Rdb_ProgressDetails *progressDetails | Statistics of device-cloud sync. |
OH_Rdb_CloudSync()
int OH_Rdb_CloudSync(OH_Rdb_Store *store, Rdb_SyncMode mode, const char *tables[], uint32_t count,const Rdb_ProgressObserver *observer)
Description
Performs device-cloud sync.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| Rdb_SyncMode mode | Type of the sync process (Rdb_SyncMode). |
| const char *tables[] | Pointer to the names of the tables to be synced. |
| uint32_t count | Number of tables to sync. If the value is 0, all tables in the RDB store are synced. |
| const Rdb_ProgressObserver *observer | Pointer to the Rdb_ProgressObserver instance. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_SubscribeAutoSyncProgress()
int OH_Rdb_SubscribeAutoSyncProgress(OH_Rdb_Store *store, const Rdb_ProgressObserver *observer)
Description
Subscribes to the auto sync progress of an RDB store.
The registered callback will be invoked to return the auto sync progress.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the target OH_Rdb_Store instance. |
| const Rdb_ProgressObserver *observer | Pointer to the Rdb_ProgressObserver instance, which invokes the callback to return the automatic sync progress. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_UnsubscribeAutoSyncProgress()
int OH_Rdb_UnsubscribeAutoSyncProgress(OH_Rdb_Store *store, const Rdb_ProgressObserver *observer)
Description
Unsubscribes from the auto sync process of an RDB store.
Since: 11
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the target OH_Rdb_Store instance. |
| const Rdb_ProgressObserver *observer | Pointer to the Rdb_ProgressObserver instance. If the pointer is null, all callbacks for the auto sync process will be unregistered. |
Returns
| Type | Description |
|---|---|
| int | Returns RDB_OK if the operation is successful; returns an error code otherwise. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_LockRow()
int OH_Rdb_LockRow(OH_Rdb_Store *store, OH_Predicates *predicates)
Description
Locks data in an RDB store based on specified conditions. The locked data will be blocked from the device-cloud sync.
Since: 12
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the lock conditions. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_UnlockRow()
int OH_Rdb_UnlockRow(OH_Rdb_Store *store, OH_Predicates *predicates)
Description
Unlocks data in an RDB store based on specified conditions.
Since: 12
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the unlock conditions. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_QueryLockedRow()
OH_Cursor *OH_Rdb_QueryLockedRow(OH_Rdb_Store *store, OH_Predicates *predicates, const char *const *columnNames, int length)
Description
Queries the locked data in an RDB store.
Since: 12
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the query conditions. |
| const char *const *columnNames | Columns to query. If null is passed in, all columns are queried. |
| int length | Length of columnNames. If the length is greater than the length of columnNames array, an out-of-bounds access will occur. |
Returns
| Type | Description |
|---|---|
| OH_Cursor | Returns the pointer to the OH_Cursor instance if the operation is successful; returns NULL otherwise. |
OH_Rdb_CreateTransaction()
int OH_Rdb_CreateTransaction(OH_Rdb_Store *store, const OH_RDB_TransOptions *options, OH_Rdb_Transaction **trans)
Description
Creates a transaction object.
Since: 18
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const OH_RDB_TransOptions *options | Pointer to the OH_RDB_TransOptions instance. |
| OH_Rdb_Transaction **trans | Double pointer to the OH_Rdb_Transaction instance if the operation is successful; otherwise, nullptr is returned. Release the memory using OH_RdbTrans_Destroy if the created transaction is used. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_ERROR indicates a common database error. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_ALREADY_CLOSED indicates that the database is already closed. RDB_E_DATABASE_BUSY indicates that the database does not respond. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_PERM indicates an SQLite error: access denied. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_NOMEM indicates an SQLite: insufficient database memory. RDB_E_SQLITE_IOERR indicates an SQLite: disk I/O error. RDB_E_SQLITE_CANT_OPEN indicates an SQLite error: unable to open the database file. |
OH_Rdb_Attach()
int OH_Rdb_Attach(OH_Rdb_Store *store, const OH_Rdb_ConfigV2 *config, const char *attachName, int64_t waitTime,size_t *attachedNumber)
Description
Attaches a database file to the database that is currently connected.
Since: 20
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance. |
| const char *attachName | Pointer to the alias of the database. |
| int64_t waitTime | Maximum duration for attaching a database, in seconds. The value ranges from 1 to 300. |
| size_t *attachedNumber | Pointer to the number of attached databases. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_ERROR indicates a common database error. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_ALREADY_CLOSED indicates that the database is already closed. RDB_E_NOT_SUPPORTED indicates that the operation is not supported. RDB_E_DATABASE_BUSY indicates that the database does not respond. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_PERM indicates an SQLite error: access denied. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_LOCKED indicates an SQLite error: database table locked. RDB_E_SQLITE_NOMEM indicates an SQLite: insufficient database memory. RDB_E_SQLITE_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite: disk I/O error. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_CONSTRAINT indicates an SQLite error code: SQLite constraint. |
OH_Rdb_Detach()
int OH_Rdb_Detach(OH_Rdb_Store *store, const char *attachName, int64_t waitTime, size_t *attachedNumber)
Description
Detaches a specified store from the current database.
Since: 20
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *attachName | Pointer to the alias of the database. |
| int64_t waitTime | Maximum duration for detaching a database, in seconds. The value ranges from 1 to 300. |
| size_t *attachedNumber | Pointer to the number of attached databases. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_ERROR indicates a common database error. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_ALREADY_CLOSED indicates that the database is already closed. RDB_E_NOT_SUPPORTED indicates that the operation is not supported. RDB_E_DATABASE_BUSY indicates that the database does not respond. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_PERM indicates an SQLite error: access denied. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_LOCKED indicates an SQLite error: database table locked. RDB_E_SQLITE_NOMEM indicates an SQLite: insufficient database memory. RDB_E_SQLITE_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite: disk I/O error. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_CONSTRAINT indicates an SQLite error code: SQLite constraint. |
OH_Rdb_SetLocale()
int OH_Rdb_SetLocale(OH_Rdb_Store *store, const char *locale)
Description
Sets locale.
Since: 20
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *locale | Pointer to the locale to set, for example, zh. The value must comply with the ISO 639 standard. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_ERR indicates that the operation fails. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_ALREADY_CLOSED indicates that the database is already closed. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_NOMEM indicates an SQLite: insufficient database memory. |
OH_Rdb_RekeyEx()
int OH_Rdb_RekeyEx(OH_Rdb_Store *store, OH_Rdb_CryptoParam *param)
Description
Changes the key used to encrypt the database.
Key update is not supported for databases in non-WAL mode.
Manual update requires exclusive access to the database. If any result set, transaction, or database opened by another process is not released, the update will fail.
Parameter update for an encrypted database and conversion between an encrypted database and a non-encrypted database are supported.
The larger the database, the longer the update takes.
Exercise caution when changing the encryption parameters. The correct encryption parameters must be passed when OH_Rdb_CreateOrOpen is called. Otherwise, the database may fail to be opened.
Since: 22
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_Rdb_CryptoParam *param | Pointer to the OH_Rdb_CryptoParam instance. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_ERROR indicates a common database error. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_ALREADY_CLOSED indicates that the database is already closed. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_PERM indicates an SQLite error: access denied. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_NOMEM indicates an SQLite: insufficient database memory. RDB_E_SQLITE_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite: disk I/O error. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. |
Rdb_CorruptedHandler()
typedef void (*Rdb_CorruptedHandler)(void *context, OH_Rdb_ConfigV2 *config, OH_Rdb_Store *store)
Description
Defines a handler for processing database exceptions.
Since: 22
Parameters
| Parameter | Description |
|---|---|
| void *context | Pointer to the context of the handler. The lifecycle is managed by the service. |
| OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 object, that is, the database configuration related to the RDB storage. This parameter cannot be used outside the callback function. |
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance, which is generated by the system and is released immediately after the callback function ends. This parameter cannot be used outside the callback function. |
OH_Rdb_RegisterCorruptedHandler()
int OH_Rdb_RegisterCorruptedHandler(const OH_Rdb_ConfigV2 *config, void *context, const Rdb_CorruptedHandler handler)
Description
Registers a handler for processing database exceptions. When a database exception occurs, this handler is called.
The exception handling logic is user-defined. You should ensure the service quality each time the callback is triggered.
Only one handler can be registered for each path.
Since: 22
Parameters
| Parameter | Description |
|---|---|
| const OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| void *context | Pointer to the context of the handler. |
| const Rdb_CorruptedHandler handler | Handler for processing database exceptions. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_SUB_LIMIT_REACHED indicates that the number of registration exceeds the upper limit. |
OH_Rdb_UnregisterCorruptedHandler()
int OH_Rdb_UnregisterCorruptedHandler(const OH_Rdb_ConfigV2 *config, void *context, const Rdb_CorruptedHandler handler)
Description
Unregisters the handler for processing database exceptions.
The handler and context must be the same as those during subscription. Otherwise, the operation fails.
Since: 22
Parameters
| Parameter | Description |
|---|---|
| const OH_Rdb_ConfigV2 *config | Pointer to the OH_Rdb_ConfigV2 instance, which is the configuration of the RDB store. |
| void *context | Pointer to the context of the handler. |
| const Rdb_CorruptedHandler handler | Handler for processing database exceptions. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_Rdb_QueryWithoutRowCount()
OH_Cursor *OH_Rdb_QueryWithoutRowCount(OH_Rdb_Store *store, OH_Predicates *predicates, const char * const columns[], int length)
Description
Queries data from the database based on specified conditions without calculating the row count.
Since: 23
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the query conditions. |
| const char * const columns[] | Columns to query. If null is passed in, all columns are queried. |
| int length | Length of columns. If the length is greater than the actual length of the columns array, an out-of-bounds access will occur. |
Returns
| Type | Description |
|---|---|
| OH_Cursor * | Returns a pointer to the OH_Cursor instance if the operation is successful; returns nullptr if the store acquisition fails or the result set is empty. |
OH_Rdb_QuerySqlWithoutRowCount()
OH_Cursor *OH_Rdb_QuerySqlWithoutRowCount(OH_Rdb_Store *store, const char *sql, const OH_Data_Values *args)
Description
Executes an SQL statement with a return value. This function does not calculate the row count, and supports vector stores.
Since: 23
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *sql | SQL statement to execute. |
| const OH_Data_Values *args | Pointer to the OH_Data_Values instance. If the SQL statement is complete, args can be set to nullptr. |
Returns
| Type | Description |
|---|---|
| OH_Cursor * | Returns a pointer to the OH_Cursor instance if the operation is successful; returns nullptr if the SQL statement is invalid or the memory allocation fails. |
OH_Rdb_BatchInsertWithReturning()
int OH_Rdb_BatchInsertWithReturning(OH_Rdb_Store *store, const char *table, const OH_Data_VBuckets *rows, Rdb_ConflictResolution resolution, OH_RDB_ReturningContext *context)
Description
Inserts batch data into the target table and outputs the change information to the context.
A maximum of 32,766 parameters can be inserted at a time. If the number of parameters exceeds this limit, the error code RDB_E_INVALID_ARGS is returned.
The number of inserted data records multiplied by the size of the union set of all fields in the inserted data equals the number of parameters.
For example, if the size of the union set is 10, a maximum of 3,276 data records can be inserted (3276 × 10 = 32760).
Ensure that you comply with this constraint when calling this API to avoid errors caused by excessive parameters.
Since: 23
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| const char *table | Name of the target table for data insertion. |
| const OH_Data_VBuckets *rows | Row of data to insert. |
| Rdb_ConflictResolution resolution | Rdb_ConflictResolution policy used to resolve file conflicts. RDB_CONFLICT_FAIL is not recommended, as an exception will be thrown upon failure and the actual change data cannot be obtained properly. |
| OH_RDB_ReturningContext *context | Pointer to the OH_RDB_ReturningContext instance. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_WAL_SIZE_OVER_LIMIT indicates that the size of the WAL log file exceeds the default value. RDB_E_NOT_SUPPORTED indicates that the operation is not supported. RDB_E_DATABASE_BUSY indicates that the database is busy. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_LOCKED indicates an SQLite error: database table locked. RDB_E_SQLITE_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite error: disk I/O error occurs. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_CONSTRAINT indicates an SQLite error: aborted due to constraint violation. RDB_E_SQLITE_ERROR indicates an SQLite error. Possible causes include syntax errors. For example, the specified table or column does not exist. For details about the error codes, see OH_Rdb_ErrCode. |
OH_Rdb_UpdateWithReturning()
int OH_Rdb_UpdateWithReturning(OH_Rdb_Store *store, OH_VBucket *row, OH_Predicates *predicates, Rdb_ConflictResolution resolution, OH_RDB_ReturningContext *context)
Description
Updates data in the database based on specified conditions and outputs the change information to the context.
Since: 23
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_VBucket *row | Row of data to update. |
| OH_Predicates *predicates | Pointer to the OH_Predicates instance. |
| Rdb_ConflictResolution resolution | Rdb_ConflictResolution policy used to resolve file conflicts. RDB_CONFLICT_FAIL is not recommended, as an exception will be thrown upon failure and the actual change data cannot be obtained properly. |
| OH_RDB_ReturningContext *context | Pointer to the OH_RDB_ReturningContext instance. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_WAL_SIZE_OVER_LIMIT indicates that the size of the WAL log file exceeds the default value. RDB_E_NOT_SUPPORTED indicates that the operation is not supported. RDB_E_EMPTY_VALUES_BUCKET indicates that the value bucket is empty. RDB_E_DATABASE_BUSY indicates that the database is busy. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_LOCKED indicates an SQLite error: database table locked. RDB_E_SQLITE_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite error: disk I/O error occurs. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_CONSTRAINT indicates an SQLite error: aborted due to constraint violation. RDB_E_SQLITE_ERROR indicates an SQLite error. Possible causes include syntax errors. For example, the specified table or column does not exist. For details about the error codes, see OH_Rdb_ErrCode. |
OH_Rdb_DeleteWithReturning()
int OH_Rdb_DeleteWithReturning(OH_Rdb_Store *store, OH_Predicates *predicates, OH_RDB_ReturningContext *context)
Description
Deletes data from the database based on specified conditions and outputs the change information to the context.
Since: 23
Parameters
| Parameter | Description |
|---|---|
| OH_Rdb_Store *store | Pointer to the OH_Rdb_Store instance. |
| OH_Predicates *predicates | Pointer to the OH_Predicates instance. |
| OH_RDB_ReturningContext *context | Pointer to the OH_RDB_ReturningContext instance. |
Returns
| Type | Description |
|---|---|
| int | Returns the operation result. RDB_OK indicates that the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. RDB_E_WAL_SIZE_OVER_LIMIT indicates that the size of the WAL log file exceeds the default value. RDB_E_NOT_SUPPORTED indicates that the operation is not supported. RDB_E_DATABASE_BUSY indicates that the database is busy. RDB_E_SQLITE_FULL indicates an SQLite error: the database is full. RDB_E_SQLITE_CORRUPT indicates that the database is corrupted. RDB_E_SQLITE_BUSY indicates an SQLite error: database file locked. RDB_E_SQLITE_LOCKED indicates an SQLite error: database table locked. RDB_E_SQLITE_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite error: disk I/O error occurs. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_ERROR indicates an SQLite error. Possible causes include syntax errors. For example, the specified table or column does not exist. For details about the error codes, see OH_Rdb_ErrCode. |
你可能感兴趣的鸿蒙文章
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