oh_rdb_transaction.h
Overview
Defines APIs and enums related to transactions.
File to include: <database/rdb/oh_rdb_transaction.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_TransOptions | OH_RDB_TransOptions | Defines the OH_RDB_TransOptions struct. |
| OH_Rdb_Transaction | OH_Rdb_Transaction | Defines the OH_RDB_TransOptions struct. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| OH_RDB_TransType | OH_RDB_TransType | Enumerates the transaction types of an RDB store. |
Functions
Enum Description
OH_RDB_TransType
enum OH_RDB_TransType
Description
Enumerates the transaction types of an RDB store.
Since: 18
| Enum Item | Description |
|---|---|
| RDB_TRANS_DEFERRED = 0 | Do not start any transaction before the database is accessed for the first time. |
| RDB_TRANS_IMMEDIATE | Start new writes without waiting for the write statement once the database is connected. |
| RDB_TRANS_EXCLUSIVE | Start the write transaction immediately, similar to RDB_TRANS_IMMEDIATE. In WAL mode, RDB_TRANS_EXCLUSIVE is the same as RDB_TRANS_IMMEDIATE. In other log modes, RDB_TRANS_EXCLUSIVE prevents other database connections when the transaction is reading the database. |
| RDB_TRANS_BUTT | Maximum value of the RDB transaction type. |
Function Description
OH_RdbTrans_CreateOptions()
OH_RDB_TransOptions *OH_RdbTrans_CreateOptions(void)
Description
Creates a transaction configuration object.
Since: 18
Returns
| Type | Description |
|---|---|
| OH_RDB_TransOptions | Returns a pointer to the OH_RDB_TransOptions instance if the operation is successful; returns nullptr otherwise. Use OH_RdbTrans_DestroyOptions to release the memory in time. |
OH_RdbTrans_DestroyOptions()
int OH_RdbTrans_DestroyOptions(OH_RDB_TransOptions *options)
Description
Destroys a TransOptions instance.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_RDB_TransOptions *options | Pointer to the OH_RDB_TransOptions instance. |
Returns
| Type | Description |
|---|---|
| int | Returns an error code. RDB_OK indicates the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_RdbTransOption_SetType()
int OH_RdbTransOption_SetType(OH_RDB_TransOptions *options, OH_RDB_TransType type)
Description
Sets the transaction type of an RDB store.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_RDB_TransOptions *options | Pointer to the OH_RDB_TransOptions instance. |
| OH_RDB_TransType type | Transaction type to set. |
Returns
| Type | Description |
|---|---|
| int | Returns an error code. RDB_OK indicates the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_RdbTrans_Commit()
int OH_RdbTrans_Commit(OH_Rdb_Transaction *trans)
Description
Commits a transaction.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
Returns
| Type | Description |
|---|---|
| int | Returns the execution result. RDB_OK indicates 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_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_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite: disk I/O error. |
OH_RdbTrans_Rollback()
int OH_RdbTrans_Rollback(OH_Rdb_Transaction *trans)
Description
Rolls back a transaction.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
Returns
| Type | Description |
|---|---|
| int | Returns the execution result. RDB_OK indicates 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_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_READONLY indicates an SQLite error: attempt to write a read-only database. RDB_E_SQLITE_IOERR indicates an SQLite: disk I/O error. |
OH_RdbTrans_Insert()
int OH_RdbTrans_Insert(OH_Rdb_Transaction *trans, const char *table, const OH_VBucket *row, int64_t *rowId)
Description
Inserts a row of data into a table.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const char *table | Name of the target table for data insertion. |
| const OH_VBucket *row | Row of data to insert. |
| int64_t *rowId | Pointer to the row number returned. |
Returns
| Type | Description |
|---|---|
| int | Returns the execution result. RDB_OK indicates 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 limit. 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 size limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. |
OH_RdbTrans_InsertWithConflictResolution()
int OH_RdbTrans_InsertWithConflictResolution(OH_Rdb_Transaction *trans, const char *table, const OH_VBucket *row,Rdb_ConflictResolution resolution, int64_t *rowId)
Description
Inserts a row of data into a table with conflict resolutions.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const char *table | Name of the target table for data insertion. |
| const OH_VBucket *row | 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 execution result. RDB_OK indicates 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 limit. 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 size limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_CONSTRAINT indicates an SQLite error code: SQLite constraint. |
OH_RdbTrans_BatchInsert()
int OH_RdbTrans_BatchInsert(OH_Rdb_Transaction *trans, 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
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const char *table | Name of the target table for data insertion. |
| 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 execution result. RDB_OK indicates 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 limit. 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 size limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_CONSTRAINT indicates an SQLite error code: SQLite constraint. |
OH_RdbTrans_Update()
int OH_RdbTrans_Update(OH_Rdb_Transaction *trans, const OH_VBucket *row, const OH_Predicates *predicates, int64_t *changes)
Description
Updates data in an RDB store based on specified conditions.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const OH_VBucket *row | Row of data to update. |
| const OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the update conditions. |
| int64_t *changes | Pointer to the number of successful updates. |
Returns
| Type | Description |
|---|---|
| int | Returns the execution result. RDB_OK indicates 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 limit. 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 size limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. |
OH_RdbTrans_UpdateWithConflictResolution()
int OH_RdbTrans_UpdateWithConflictResolution(OH_Rdb_Transaction *trans, const OH_VBucket *row,const 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
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const OH_VBucket *row | Row of data to update. |
| const 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 successful updates. |
Returns
| Type | Description |
|---|---|
| int | Returns the execution result. RDB_OK indicates 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 limit. 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 size limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. RDB_E_SQLITE_CONSTRAINT indicates an SQLite error code: SQLite constraint. |
OH_RdbTrans_Delete()
int OH_RdbTrans_Delete(OH_Rdb_Transaction *trans, const OH_Predicates *predicates, int64_t *changes)
Description
Deletes data from the database based on specified conditions.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the deletion conditions. |
| int64_t *changes | Pointer to the number of successful deletions. |
Returns
| Type | Description |
|---|---|
| int | Returns the execution result. RDB_OK indicates 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 limit. 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 size limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. |
OH_RdbTrans_Query()
OH_Cursor *OH_RdbTrans_Query(OH_Rdb_Transaction *trans, const OH_Predicates *predicates, const char *columns[], int len)
Description
Queries data from the database based on specified conditions.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const OH_Predicates *predicates | Pointer to the OH_Predicates instance, specifying the query conditions. |
| const char *columns[] | Columns to query. If null is passed in, all columns are queried. |
| int len | Number of elements in a column. |
Returns
| Type | Description |
|---|---|
| OH_Cursor | Returns a pointer to the OH_Cursor instance if the operation is successful; returns null if the database is closed or does not respond. |
OH_RdbTrans_QuerySql()
OH_Cursor *OH_RdbTrans_QuerySql(OH_Rdb_Transaction *trans, const char *sql, const OH_Data_Values *args)
Description
Queries data from the database based on the SQL statement.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const char *sql | Pointer to the SQL statement to execute. |
| const OH_Data_Values *args | Pointer to OH_Data_Values. |
Returns
| Type | Description |
|---|---|
| OH_Cursor | Returns a pointer to the OH_Cursor instance if the operation is successful; returns null if the database is closed or does not respond. |
OH_RdbTrans_Execute()
int OH_RdbTrans_Execute(OH_Rdb_Transaction *trans, const char *sql, const OH_Data_Values *args, OH_Data_Value **result)
Description
Executes an SQL statement that contains specified parameters.
Statements starting with comments are not supported.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const char *sql | Pointer to the SQL statement to execute. |
| const OH_Data_Values *args | Pointer to the parameters contained in the SQL statement. |
| OH_Data_Value **result | Double pointer to the OH_Data_Value instance. After the execution is complete, you must release the memory by calling OH_Value_Destroy. |
Returns
| Type | Description |
|---|---|
| int | Returns the execution result. RDB_OK indicates 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 limit. 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 size limit. RDB_E_SQLITE_MISMATCH indicates an SQLite error: data types mismatch. |
OH_RdbTrans_Destroy()
int OH_RdbTrans_Destroy(OH_Rdb_Transaction *trans)
Description
Destroys a transaction object.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
Returns
| Type | Description |
|---|---|
| int | Returns an error code. RDB_OK indicates the operation is successful. RDB_E_INVALID_ARGS indicates that invalid parameters are specified. |
OH_RdbTrans_QueryWithoutRowCount()
OH_Cursor *OH_RdbTrans_QueryWithoutRowCount(OH_Rdb_Transaction *trans, const OH_Predicates *predicates, const char * const columns[], int len)
Description
Queries data from the database based on specified conditions without calculating the row count.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const OH_Predicates *predicates | Query conditions specified by OH_Predicates. |
| const char * const columns[] | Columns to query. If null is passed in, all columns are queried. |
| int len | Length of the input columns array. If len 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 a null pointer if the database is closed or does not respond. |
OH_RdbTrans_QuerySqlWithoutRowCount()
OH_Cursor *OH_RdbTrans_QuerySqlWithoutRowCount(OH_Rdb_Transaction *trans, const char *sql, const OH_Data_Values *args)
Description
Queries data from the database based on the SQL statement without calculating the row count.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction instance. |
| const char *sql | SQL statement to execute. |
| const OH_Data_Values *args | Pointer to OH_Data_Values. |
Returns
| Type | Description |
|---|---|
| OH_Cursor * | Returns a pointer to the OH_Cursor instance if the operation is successful; returns a null pointer if the database is closed or does not respond. |
OH_RdbTrans_BatchInsertWithReturning()
int OH_RdbTrans_BatchInsertWithReturning(OH_Rdb_Transaction *trans, 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
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction 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 execution result. RDB_OK indicates 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 limit. RDB_E_NOT_SUPPORTED indicates that the operation is not supported. RDB_E_DATABASE_BUSY indicates that the database is busy. RDB_E_ALREADY_CLOSED indicates that the database is already closed. 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_IOERR indicates an SQLite error: disk I/O error occurs. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the size 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_RdbTrans_UpdateWithReturning()
int OH_RdbTrans_UpdateWithReturning(OH_Rdb_Transaction *trans, 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
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction 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 execution result. RDB_OK indicates 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 limit. 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_ALREADY_CLOSED indicates that the database is already closed. 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_IOERR indicates an SQLite error: disk I/O error occurs. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the size 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_RdbTrans_DeleteWithReturning()
int OH_RdbTrans_DeleteWithReturning(OH_Rdb_Transaction *trans, 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
| Name | Description |
|---|---|
| OH_Rdb_Transaction *trans | Pointer to the OH_Rdb_Transaction 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 execution result. RDB_OK indicates 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 limit. RDB_E_NOT_SUPPORTED indicates that the operation is not supported. RDB_E_DATABASE_BUSY indicates that the database is busy. RDB_E_ALREADY_CLOSED indicates that the database is already closed. 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_IOERR indicates an SQLite error: disk I/O error occurs. RDB_E_SQLITE_TOO_BIG indicates an SQLite error: TEXT or BLOB exceeds the size 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