1# oh_rdb_transaction.h 2 3## Overview 4 5Defines APIs and enums related to transactions. 6 7**File to include**: <database/rdb/oh_rdb_transaction.h> 8 9**Library**: libnative_rdb_ndk.z.so 10 11**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 12 13**Since**: 18 14 15**Related module**: [RDB](capi-rdb.md) 16 17## Summary 18 19### Structs 20 21| Name | typedef Keyword | Description | 22| -------------------------------------------------- | ------------------- | ------------------------------------------------------------ | 23| [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) | OH_RDB_TransOptions | Defines the [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) struct.| 24| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) | OH_Rdb_Transaction | Defines the [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) struct.| 25 26### Enums 27 28| Name | typedef Keyword | Description | 29| ------------------------------------- | ---------------- | -------------------------- | 30| [OH_RDB_TransType](#oh_rdb_transtype) | OH_RDB_TransType | Enumerates the transaction types of an RDB store.| 31 32### Functions 33 34| Name | Description | 35| ------------------------------------------------------------ | ------------------------------------------------------------ | 36| [OH_RDB_TransOptions *OH_RdbTrans_CreateOptions(void)](#oh_rdbtrans_createoptions) | Creates a **TransOptions** instance. | 37| [int OH_RdbTrans_DestroyOptions(OH_RDB_TransOptions *options)](#oh_rdbtrans_destroyoptions) | Destroys a **TransOptions** instance. | 38| [int OH_RdbTransOption_SetType(OH_RDB_TransOptions *options, OH_RDB_TransType type)](#oh_rdbtransoption_settype) | Sets the transaction type of an RDB store. | 39| [int OH_RdbTrans_Commit(OH_Rdb_Transaction *trans)](#oh_rdbtrans_commit) | Commits a transaction. | 40| [int OH_RdbTrans_Rollback(OH_Rdb_Transaction *trans)](#oh_rdbtrans_rollback) | Rolls back a transaction. | 41| [int OH_RdbTrans_Insert(OH_Rdb_Transaction *trans, const char *table, const OH_VBucket *row, int64_t *rowId)](#oh_rdbtrans_insert) | Inserts a row of data into a table. | 42| [int OH_RdbTrans_InsertWithConflictResolution(OH_Rdb_Transaction *trans, const char *table, const OH_VBucket *row,Rdb_ConflictResolution resolution, int64_t *rowId)](#oh_rdbtrans_insertwithconflictresolution) | Inserts a row of data into a table with conflict resolutions. | 43| [int OH_RdbTrans_BatchInsert(OH_Rdb_Transaction *trans, const char *table, const OH_Data_VBuckets *rows,Rdb_ConflictResolution resolution, int64_t *changes)](#oh_rdbtrans_batchinsert) | Inserts a batch of data into a table. | 44| [int OH_RdbTrans_Update(OH_Rdb_Transaction *trans, const OH_VBucket *row, const OH_Predicates *predicates,int64_t *changes)](#oh_rdbtrans_update) | Updates data in an RDB store based on specified conditions. | 45| [int OH_RdbTrans_UpdateWithConflictResolution(OH_Rdb_Transaction *trans, const OH_VBucket *row,const OH_Predicates *predicates, Rdb_ConflictResolution resolution, int64_t *changes)](#oh_rdbtrans_updatewithconflictresolution) | Updates data in the database based on specified conditions and supports conflict resolution. | 46| [int OH_RdbTrans_Delete(OH_Rdb_Transaction *trans, const OH_Predicates *predicates, int64_t *changes)](#oh_rdbtrans_delete) | Deletes data from the database based on the specified conditions. | 47| [OH_Cursor *OH_RdbTrans_Query(OH_Rdb_Transaction *trans, const OH_Predicates *predicates, const char *columns[],int len)](#oh_rdbtrans_query) | Queries data in the database based on specified conditions. | 48| [OH_Cursor *OH_RdbTrans_QuerySql(OH_Rdb_Transaction *trans, const char *sql, const OH_Data_Values *args)](#oh_rdbtrans_querysql) | Queries data in the database using the specified SQL statement. | 49| [int OH_RdbTrans_Execute(OH_Rdb_Transaction *trans, const char *sql, const OH_Data_Values *args, OH_Data_Value **result)](#oh_rdbtrans_execute) | Executes an SQL statement that contains specified parameters. | 50| [int OH_RdbTrans_Destroy(OH_Rdb_Transaction *trans)](#oh_rdbtrans_destroy) | Destroys a transaction object. | 51 52## Enum Description 53 54### OH_RDB_TransType 55 56``` 57enum OH_RDB_TransType 58``` 59 60**Description** 61 62Enumerates the transaction types of an RDB store. 63 64**Since**: 18 65 66| Enum Item | Description | 67| ---------------------- | ------------------------------------------------------------ | 68| RDB_TRANS_DEFERRED = 0 | Do not start any transaction before the database is accessed for the first time. | 69| RDB_TRANS_IMMEDIATE | Start new writes without waiting for the write statement once the database is connected. | 70| RDB_TRANS_EXCLUSIVE | Start the write transaction immediately, similar to **RDB_TRANS_IMMEDIATE**.<br>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.| 71| RDB_TRANS_BUTT | Maximum value of the RDB transaction type. | 72 73 74## Function Description 75 76### OH_RdbTrans_CreateOptions() 77 78``` 79OH_RDB_TransOptions *OH_RdbTrans_CreateOptions(void) 80``` 81 82**Description** 83 84Creates a transaction configuration object. 85 86**Since**: 18 87 88**Returns** 89 90| Type | Description | 91| -------------------------------------------------- | ------------------------------------------------------------ | 92| [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) | Returns a pointer to the [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) instance if the operation is successful; returns **nullptr** otherwise.<br>Use [OH_RdbTrans_DestroyOptions](capi-oh-rdb-transaction-h.md#oh_rdbtrans_destroyoptions) to release the memory in time.| 93 94### OH_RdbTrans_DestroyOptions() 95 96``` 97int OH_RdbTrans_DestroyOptions(OH_RDB_TransOptions *options) 98``` 99 100**Description** 101 102Destroys a **TransOptions** instance. 103 104**Since**: 18 105 106 107**Parameters** 108 109| Name | Description | 110| ----------------------------------------------------------- | ------------------------------------------------------------ | 111| [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) *options | Pointer to the [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) instance.| 112 113**Returns** 114 115| Type| Description | 116| ---- | ------------------------------------------------------------ | 117| int | Returns an error code.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 118 119### OH_RdbTransOption_SetType() 120 121``` 122int OH_RdbTransOption_SetType(OH_RDB_TransOptions *options, OH_RDB_TransType type) 123``` 124 125**Description** 126 127Sets the transaction type of an RDB store. 128 129**Since**: 18 130 131 132**Parameters** 133 134| Name | Description | 135| ----------------------------------------------------------- | ------------------------------------------------------------ | 136| [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) *options | Pointer to the [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) instance.| 137| [OH_RDB_TransType](#oh_rdb_transtype) type | Transaction type to set. | 138 139**Returns** 140 141| Type| Description | 142| ---- | ------------------------------------------------------------ | 143| int | Returns an error code.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 144 145### OH_RdbTrans_Commit() 146 147``` 148int OH_RdbTrans_Commit(OH_Rdb_Transaction *trans) 149``` 150 151**Description** 152 153Commits a transaction. 154 155**Since**: 18 156 157 158**Parameters** 159 160| Name | Description | 161| ------------------------------------------------------- | ------------------------------------------------------------ | 162| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 163 164**Returns** 165 166| Type| Description | 167| ---- | ------------------------------------------------------------ | 168| int | Returns the execution result.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.| 169 170### OH_RdbTrans_Rollback() 171 172``` 173int OH_RdbTrans_Rollback(OH_Rdb_Transaction *trans) 174``` 175 176**Description** 177 178Rolls back a transaction. 179 180**Since**: 18 181 182 183**Parameters** 184 185| Name | Description | 186| ------------------------------------------------------- | ------------------------------------------------------------ | 187| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 188 189**Returns** 190 191| Type| Description | 192| ---- | ------------------------------------------------------------ | 193| int | Returns the execution result.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.| 194 195### OH_RdbTrans_Insert() 196 197``` 198int OH_RdbTrans_Insert(OH_Rdb_Transaction *trans, const char *table, const OH_VBucket *row, int64_t *rowId) 199``` 200 201**Description** 202 203Inserts a row of data into a table. 204 205**Since**: 18 206 207 208**Parameters** 209 210| Name | Description | 211| ------------------------------------------------------- | ------------------------------------------------------------ | 212| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 213| const char *table | Pointer to the target table. | 214| const [OH_VBucket](capi-rdb-oh-vbucket.md) *row | Row of data to insert. | 215| int64_t *rowId | Pointer to the row number returned. | 216 217**Returns** 218 219| Type| Description | 220| ---- | ------------------------------------------------------------ | 221| int | Returns the execution result.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.| 222 223### OH_RdbTrans_InsertWithConflictResolution() 224 225``` 226int OH_RdbTrans_InsertWithConflictResolution(OH_Rdb_Transaction *trans, const char *table, const OH_VBucket *row,Rdb_ConflictResolution resolution, int64_t *rowId) 227``` 228 229**Description** 230 231Inserts a row of data into a table with conflict resolutions. 232 233**Since**: 20 234 235 236**Parameters** 237 238| Name | Description | 239| ------------------------------------------------------- | ------------------------------------------------------------ | 240| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 241| const char *table | Name of the target table. | 242| const [OH_VBucket](capi-rdb-oh-vbucket.md) *row | Pointer to the row of data to insert. | 243| Rdb_ConflictResolution resolution | Policy used to resolve file conflicts. | 244| int64_t *rowId | Pointer to the row number returned. | 245 246**Returns** 247 248| Type| Description | 249| ---- | ------------------------------------------------------------ | 250| int | Returns the execution result.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.<br>**RDB_E_SQLITE_CONSTRAINT** indicates an SQLite error code: SQLite constraint.| 251 252### OH_RdbTrans_BatchInsert() 253 254``` 255int OH_RdbTrans_BatchInsert(OH_Rdb_Transaction *trans, const char *table, const OH_Data_VBuckets *rows,Rdb_ConflictResolution resolution, int64_t *changes) 256``` 257 258**Description** 259 260Inserts a batch of data into a table. 261 262**Since**: 18 263 264 265**Parameters** 266 267| Name | Description | 268| -------------------------------------------------------- | ------------------------------------------------------------ | 269| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 270| const char *table | Pointer to the target table. | 271| const [OH_Data_VBuckets](capi-rdb-oh-data-vbuckets.md) *rows | An array of data to insert. | 272| Rdb_ConflictResolution resolution | Policy used to resolve file conflicts. | 273| int64_t *changes | Pointer to the number of successful insertions. | 274 275**Returns** 276 277| Type| Description | 278| ---- | ------------------------------------------------------------ | 279| int | Returns the execution result.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.<br>**RDB_E_SQLITE_CONSTRAINT** indicates an SQLite error code: SQLite constraint.| 280 281### OH_RdbTrans_Update() 282 283``` 284int OH_RdbTrans_Update(OH_Rdb_Transaction *trans, const OH_VBucket *row, const OH_Predicates *predicates,int64_t *changes) 285``` 286 287**Description** 288 289Updates data in an RDB store based on specified conditions. 290 291**Since**: 18 292 293 294**Parameters** 295 296| Name | Description | 297| -------------------------------------------------------- | ------------------------------------------------------------ | 298| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 299| const [OH_VBucket](capi-rdb-oh-vbucket.md) *row | Pointer to the row of data to update. | 300| const [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the update conditions. | 301| int64_t *changes | Pointer to the number of successful updates. | 302 303**Returns** 304 305| Type| Description | 306| ---- | ------------------------------------------------------------ | 307| int | Returns the execution result.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.| 308 309### OH_RdbTrans_UpdateWithConflictResolution() 310 311``` 312int OH_RdbTrans_UpdateWithConflictResolution(OH_Rdb_Transaction *trans, const OH_VBucket *row,const OH_Predicates *predicates, Rdb_ConflictResolution resolution, int64_t *changes) 313``` 314 315**Description** 316 317Updates data in the database based on specified conditions and supports conflict resolution. 318 319**Since**: 20 320 321 322**Parameters** 323 324| Name | Description | 325| -------------------------------------------------------- | ------------------------------------------------------------ | 326| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 327| const [OH_VBucket](capi-rdb-oh-vbucket.md) *row | Pointer to the row of data to update. | 328| const [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the update conditions. | 329| Rdb_ConflictResolution resolution | Policy used to resolve file conflicts. | 330| int64_t *changes | Pointer to the number of successful updates. | 331 332**Returns** 333 334| Type| Description | 335| ---- | ------------------------------------------------------------ | 336| int | Returns the execution result.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.<br>**RDB_E_SQLITE_CONSTRAINT** indicates an SQLite error code: SQLite constraint.| 337 338### OH_RdbTrans_Delete() 339 340``` 341int OH_RdbTrans_Delete(OH_Rdb_Transaction *trans, const OH_Predicates *predicates, int64_t *changes) 342``` 343 344**Description** 345 346Deletes data from the database based on the specified conditions. 347 348**Since**: 18 349 350 351**Parameters** 352 353| Name | Description | 354| -------------------------------------------------------- | ------------------------------------------------------------ | 355| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 356| const [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the deletion conditions. | 357| int64_t *changes | Pointer to the number of successful deletions. | 358 359**Returns** 360 361| Type| Description | 362| ---- | ------------------------------------------------------------ | 363| int | Returns the execution result.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.| 364 365### OH_RdbTrans_Query() 366 367``` 368OH_Cursor *OH_RdbTrans_Query(OH_Rdb_Transaction *trans, const OH_Predicates *predicates, const char *columns[],int len) 369``` 370 371**Description** 372 373Queries data in the database based on specified conditions. 374 375**Since**: 18 376 377 378**Parameters** 379 380| Name | Description | 381| -------------------------------------------------------- | ------------------------------------------------------------ | 382| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 383| const [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the query conditions. | 384| columns | Pointer to the column to be queried. If the value is not specified, the query applies to all columns. | 385| int len | Number of elements in a column. | 386 387**Returns** 388 389| Type | Description | 390| ------------------------------ | ------------------------------------------------------------ | 391| [OH_Cursor](capi-rdb-oh-cursor.md) | Returns a pointer to the [OH_Cursor](capi-rdb-oh-cursor.md) instance if the operation is successful; returns null if the database is closed or does not respond.| 392 393### OH_RdbTrans_QuerySql() 394 395``` 396OH_Cursor *OH_RdbTrans_QuerySql(OH_Rdb_Transaction *trans, const char *sql, const OH_Data_Values *args) 397``` 398 399**Description** 400 401Queries data in the database using the specified SQL statement. 402 403**Since**: 18 404 405 406**Parameters** 407 408| Name | Description | 409| ------------------------------------------------------- | ------------------------------------------------------------ | 410| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 411| const char *sql | Pointer to the SQL statement to execute. | 412| const [OH_Data_Values](capi-rdb-oh-data-values.md) *args | Pointer to the [OH_Data_Values](capi-rdb-oh-data-values.md) instance. | 413 414**Returns** 415 416| Type | Description | 417| ------------------------------ | ------------------------------------------------------------ | 418| [OH_Cursor](capi-rdb-oh-cursor.md) | Returns a pointer to the [OH_Cursor](capi-rdb-oh-cursor.md) instance if the operation is successful; returns null if the database is closed or does not respond.| 419 420### OH_RdbTrans_Execute() 421 422``` 423int OH_RdbTrans_Execute(OH_Rdb_Transaction *trans, const char *sql, const OH_Data_Values *args, OH_Data_Value **result) 424``` 425 426**Description** 427 428Executes an SQL statement that contains specified parameters. 429 430**Since**: 18 431 432 433**Parameters** 434 435| Name | Description | 436| ------------------------------------------------------- | ------------------------------------------------------------ | 437| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 438| const char *sql | Pointer to the SQL statement to execute. | 439| const [OH_Data_Values](capi-rdb-oh-data-values.md) *args | Pointer to the parameters contained in the SQL statement. | 440| OH_Data_Value **result | Double pointer to the [OH_Data_Value](capi-rdb-oh-data-value.md) instance. After the execution is complete, you must release the memory by calling [OH_Value_Destroy](capi-oh-data-value-h.md#oh_value_destroy).| 441 442**Returns** 443 444| Type| Description | 445| ---- | ------------------------------------------------------------ | 446| int | Returns the execution result.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.| 447 448### OH_RdbTrans_Destroy() 449 450``` 451int OH_RdbTrans_Destroy(OH_Rdb_Transaction *trans) 452``` 453 454**Description** 455 456Destroys a transaction object. 457 458**Since**: 18 459 460 461**Parameters** 462 463| Name | Description | 464| ------------------------------------------------------- | ------------------------------------------------------------ | 465| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) *trans | Pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance.| 466 467**Returns** 468 469| Type| Description | 470| ---- | ------------------------------------------------------------ | 471| int | Returns an error code.<br>**RDB_OK** indicates the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 472