1# @ohos.data.relationalStore (RDB Store) (System API) 2 3The relational database (RDB) store manages data based on relational models. It provides a complete mechanism for managing local databases based on the underlying SQLite. To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. The worker threads are not supported. 4ArkTS supports the following basic data types: number, string, binary data, and boolean. The maximum size of a data record is 2 MB. If a data record exceeds 2 MB, it can be inserted successfully but cannot be read. 5 6The **relationalStore** module provides the following functions: 7 8- [RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates): provides predicates indicating the nature, feature, or relationship of a data entity in an RDB store. It is used to define the operation conditions for an RDB store. 9- [RdbStore](#rdbstore): provides APIs for managing data in an RDB store. 10- [ResultSet](js-apis-data-relationalStore.md#resultset): provides APIs for accessing the result set obtained from the RDB store. 11 12> **NOTE** 13> 14> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 15> 16> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.data.relationalStore](js-apis-data-relationalStore.md). 17 18## Modules to Import 19 20```ts 21import { relationalStore } from '@kit.ArkData'; 22``` 23 24## StoreConfig 25 26Defines the configuration of an RDB store. 27 28**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 29 30| Name | Type | Mandatory| Description | 31| ------------- | ------------- | ---- | --------------------------------------------------------- | 32| isSearchable<sup>11+</sup> | boolean | No| Whether the RDB store is searchable. The value **true** means the RDB store is searchable; the value **false** means the opposite. The default value is **false**.<br>**System API**: This is a system API.<br>This parameter is supported since API version 11.| 33| vector<sup>12+</sup> | boolean | No| Whether the RDB store is a vector database. The value **true** means the RDB store is a vector database, and the value **false** means the opposite.<br>The vector database is ideal for storing and managing high-dimensional vector data, while the relational database is optimal for storing and processing structured data.<br>**System API**: This is a system API.<br>This parameter is supported since API version 12. Currently, the [execute](js-apis-data-relationalStore.md#execute12-1), [querySql](js-apis-data-relationalStore.md#querysql-1), [beginTrans](js-apis-data-relationalStore.md#begintrans12), [commit](js-apis-data-relationalStore.md#commit12), [rollback](js-apis-data-relationalStore.md#rollback12), and [ResultSet](js-apis-data-relationalStore.md#resultset) APIs support vector databases.| 34| haMode<sup>12+</sup> | [HAMode](#hamode12) | No| High availability (HA) mode.<br>The value **SINGLE** means data can be written only to a single RDB store. The value **MAIN_REPLICA** means data can be written to the main and replica RDB stores to ensure HA. However, this mode is not supported in encryption and attach scenarios. The default value is **SINGLE**. The value **MAIN_REPLICA** may affect the database write performance.<br>**System API**: This is a system API.<br>This parameter is supported since API version 12.<br>| 35 36## HAMode<sup>12+</sup> 37 38Enumerates the HA modes of an RDB store. 39 40**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 41 42| Name | Value | Description | 43| ------------------------------- | --- | -------------- | 44| SINGLE | 0 | Allows data to be written to a single RDB store. | 45| MAIN_REPLICA | 1 | Allows data to be written to the main and replica RDB stores for HA. This mode is not supported in encryption and attach scenarios.| 46 47## Reference<sup>11+</sup> 48 49Represents the reference between tables by field. If table **b** references table **a**, table **a** is the source table and **b** is the target table. 50 51**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 52 53**System API**: This is a system API. 54 55| Name | Type | Mandatory| Description | 56| ---------- | ------ | ---- | ---------------------------------------- | 57| sourceTable | string | Yes | Name of the table referenced. | 58| targetTable | string | Yes | Name of the table that references the source table. | 59| refFields | Record<string, string> | Yes | Fields referenced. In a KV pair, the key indicates the field in the source table, and the value indicates the field in the target table. | 60 61## DistributedConfig<sup>10+</sup> 62 63Defines the configuration of the distributed mode of tables. 64 65**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 66 67| Name | Type | Mandatory| Description | 68| -------- | ------- | ---- | ------------------------------------------------------------ | 69| references<sup>11+</sup> | Array<[Reference](#reference11)> | No | References between tables. You can reference multiple fields, and their values must be the same in the source and target tables. By default, database tables are not referenced with each other.<br>**System API**: This is a system API.<br>This parameter is supported since API version 11.| 70 71## RdbStore 72 73Provides APIs for managing data in an RDB store. 74Before using the **RdbStore** APIs, use [executeSql](js-apis-data-relationalStore.md#executesql) to initialize the database table structure and related data. 75 76### update 77 78update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void 79 80Updates data based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail. 81 82**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 83 84**Model restriction**: This API can be used only in the stage model. 85 86**System API**: This is a system API. 87 88**Parameters** 89 90| Name | Type | Mandatory| Description | 91| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 92| table | string | Yes | Name of the target table. | 93| values | [ValuesBucket](js-apis-data-relationalStore.md#valuesbucket) | Yes | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.| 94| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Update conditions specified by the **DataSharePredicates** object. | 95| callback | AsyncCallback<number> | Yes | Callback used to return the number of rows updated. | 96 97**Error codes** 98 99For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 100 101| **ID**| **Error Message** | 102|-----------| ------------------------------------------------------------ | 103| 202 | Permission verification failed, application which is not a system application uses system API. | 104| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 105| 14800000 | Inner error. | 106| 14800011 | Database corrupted. | 107| 14800014 | Already closed. | 108| 14800015 | The database does not respond. | 109| 14800021 | SQLite: Generic error. | 110| 14800022 | SQLite: Callback routine requested an abort. | 111| 14800023 | SQLite: Access permission denied. | 112| 14800024 | SQLite: The database file is locked. | 113| 14800025 | SQLite: A table in the database is locked. | 114| 14800026 | SQLite: The database is out of memory. | 115| 14800027 | SQLite: Attempt to write a readonly database. | 116| 14800028 | SQLite: Some kind of disk I/O error occurred. | 117| 14800029 | SQLite: The database is full. | 118| 14800030 | SQLite: Unable to open the database file. | 119| 14800031 | SQLite: TEXT or BLOB exceeds size limit. | 120| 14800032 | SQLite: Abort due to constraint violation. | 121| 14800033 | SQLite: Data type mismatch. | 122| 14800034 | SQLite: Library used incorrectly. | 123| 14800047 | The WAL file size exceeds the default limit. | 124 125**Example** 126 127```ts 128import { dataSharePredicates } from '@kit.ArkData'; 129import { ValuesBucket } from '@kit.ArkData'; 130 131let value1 = "Rose"; 132let value2 = 22; 133let value3 = 200.5; 134let value4 = new Uint8Array([1, 2, 3, 4, 5]); 135 136// You can use either of the following: 137const valueBucket1: ValuesBucket = { 138 'NAME': value1, 139 'AGE': value2, 140 'SALARY': value3, 141 'CODES': value4, 142}; 143const valueBucket2: ValuesBucket = { 144 NAME: value1, 145 AGE: value2, 146 SALARY: value3, 147 CODES: value4, 148}; 149const valueBucket3: ValuesBucket = { 150 "NAME": value1, 151 "AGE": value2, 152 "SALARY": value3, 153 "CODES": value4, 154}; 155 156let predicates = new dataSharePredicates.DataSharePredicates(); 157predicates.equalTo("NAME", "Lisa"); 158if(store != undefined) { 159 (store as relationalStore.RdbStore).update("EMPLOYEE", valueBucket1, predicates, (err, rows) => { 160 if (err) { 161 console.error(`Updated failed, code is ${err.code},message is ${err.message}`); 162 return; 163 } 164 console.info(`Updated row count: ${rows}`); 165 }) 166} 167``` 168 169### update 170 171update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates):Promise<number> 172 173Updates data based on the specified **DataSharePredicates** object. This API uses a promise to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail. 174 175**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 176 177**Model restriction**: This API can be used only in the stage model. 178 179**System API**: This is a system API. 180 181**Parameters** 182 183| Name | Type | Mandatory| Description | 184| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 185| table | string | Yes | Name of the target table. | 186| values | [ValuesBucket](js-apis-data-relationalStore.md#valuesbucket) | Yes | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.| 187| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Update conditions specified by the **DataSharePredicates** object. | 188 189**Return value** 190 191| Type | Description | 192| --------------------- | ----------------------------------------- | 193| Promise<number> | Promise used to return the number of rows updated.| 194 195**Error codes** 196 197For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 198 199| **ID**| **Error Message** | 200|-----------| ------------------------------------------------------------ | 201| 202 | Permission verification failed, application which is not a system application uses system API. | 202| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 203| 14800000 | Inner error. | 204| 14800011 | Database corrupted. | 205| 14800014 | Already closed. | 206| 14800015 | The database does not respond. | 207| 14800021 | SQLite: Generic error. | 208| 14800022 | SQLite: Callback routine requested an abort. | 209| 14800023 | SQLite: Access permission denied. | 210| 14800024 | SQLite: The database file is locked. | 211| 14800025 | SQLite: A table in the database is locked. | 212| 14800026 | SQLite: The database is out of memory. | 213| 14800027 | SQLite: Attempt to write a readonly database. | 214| 14800028 | SQLite: Some kind of disk I/O error occurred. | 215| 14800029 | SQLite: The database is full. | 216| 14800030 | SQLite: Unable to open the database file. | 217| 14800031 | SQLite: TEXT or BLOB exceeds size limit. | 218| 14800032 | SQLite: Abort due to constraint violation. | 219| 14800033 | SQLite: Data type mismatch. | 220| 14800034 | SQLite: Library used incorrectly. | 221| 14800047 | The WAL file size exceeds the default limit. | 222 223**Example** 224 225```ts 226import { dataSharePredicates } from '@kit.ArkData'; 227import { ValuesBucket } from '@kit.ArkData'; 228import { BusinessError } from '@kit.BasicServicesKit'; 229 230let value1 = "Rose"; 231let value2 = 22; 232let value3 = 200.5; 233let value4 = new Uint8Array([1, 2, 3, 4, 5]); 234 235// You can use either of the following: 236const valueBucket1: ValuesBucket = { 237 'NAME': value1, 238 'AGE': value2, 239 'SALARY': value3, 240 'CODES': value4, 241}; 242const valueBucket2: ValuesBucket = { 243 NAME: value1, 244 AGE: value2, 245 SALARY: value3, 246 CODES: value4, 247}; 248const valueBucket3: ValuesBucket = { 249 "NAME": value1, 250 "AGE": value2, 251 "SALARY": value3, 252 "CODES": value4, 253}; 254 255let predicates = new dataSharePredicates.DataSharePredicates(); 256predicates.equalTo("NAME", "Lisa"); 257if(store != undefined) { 258 (store as relationalStore.RdbStore).update("EMPLOYEE", valueBucket1, predicates).then(async (rows: Number) => { 259 console.info(`Updated row count: ${rows}`); 260 }).catch((err: BusinessError) => { 261 console.error(`Updated failed, code is ${err.code},message is ${err.message}`); 262 }) 263} 264``` 265 266### delete 267 268delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void 269 270Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. 271 272**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 273 274**Model restriction**: This API can be used only in the stage model. 275 276**System API**: This is a system API. 277 278**Parameters** 279 280| Name | Type | Mandatory| Description | 281| ---------- | ------------------------------------------------------------ | ---- | --------------------------------------------- | 282| table | string | Yes | Name of the target table. | 283| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Conditions specified by the **DataSharePredicates** object for deleting data.| 284| callback | AsyncCallback<number> | Yes | Callback used to return the number of rows deleted. | 285 286**Error codes** 287 288For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 289 290| **ID**| **Error Message** | 291|-----------| ------------------------------------------------------------ | 292| 202 | Permission verification failed, application which is not a system application uses system API. | 293| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 294| 14800000 | Inner error. | 295| 14800011 | Database corrupted. | 296| 14800014 | Already closed. | 297| 14800015 | The database does not respond. | 298| 14800021 | SQLite: Generic error. | 299| 14800022 | SQLite: Callback routine requested an abort. | 300| 14800023 | SQLite: Access permission denied. | 301| 14800024 | SQLite: The database file is locked. | 302| 14800025 | SQLite: A table in the database is locked. | 303| 14800026 | SQLite: The database is out of memory. | 304| 14800027 | SQLite: Attempt to write a readonly database. | 305| 14800028 | SQLite: Some kind of disk I/O error occurred. | 306| 14800029 | SQLite: The database is full. | 307| 14800030 | SQLite: Unable to open the database file. | 308| 14800031 | SQLite: TEXT or BLOB exceeds size limit. | 309| 14800032 | SQLite: Abort due to constraint violation. | 310| 14800033 | SQLite: Data type mismatch. | 311| 14800034 | SQLite: Library used incorrectly. | 312| 14800047 | The WAL file size exceeds the default limit. | 313 314**Example** 315 316```ts 317import { dataSharePredicates } from '@kit.ArkData'; 318 319let predicates = new dataSharePredicates.DataSharePredicates(); 320predicates.equalTo("NAME", "Lisa"); 321if(store != undefined) { 322 (store as relationalStore.RdbStore).delete("EMPLOYEE", predicates, (err, rows) => { 323 if (err) { 324 console.error(`Delete failed, code is ${err.code},message is ${err.message}`); 325 return; 326 } 327 console.info(`Delete rows: ${rows}`); 328 }) 329} 330``` 331 332### delete 333 334delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promise<number> 335 336Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result. 337 338**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 339 340**Model restriction**: This API can be used only in the stage model. 341 342**System API**: This is a system API. 343 344**Parameters** 345 346| Name | Type | Mandatory| Description | 347| ---------- | ------------------------------------------------------------ | ---- | --------------------------------------------- | 348| table | string | Yes | Name of the target table. | 349| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Conditions specified by the **DataSharePredicates** object for deleting data.| 350 351**Return value** 352 353| Type | Description | 354| --------------------- | ------------------------------- | 355| Promise<number> | Promise used to return the number of rows deleted.| 356 357**Error codes** 358 359For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 360 361| **ID**| **Error Message** | 362|-----------| --------------------- | 363| 202 | Permission verification failed, application which is not a system application uses system API. | 364| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 365| 14800000 | Inner error. | 366| 14800011 | Database corrupted. | 367| 14800014 | Already closed. | 368| 14800015 | The database does not respond. | 369| 14800021 | SQLite: Generic error. | 370| 14800022 | SQLite: Callback routine requested an abort. | 371| 14800023 | SQLite: Access permission denied. | 372| 14800024 | SQLite: The database file is locked. | 373| 14800025 | SQLite: A table in the database is locked. | 374| 14800026 | SQLite: The database is out of memory. | 375| 14800027 | SQLite: Attempt to write a readonly database. | 376| 14800028 | SQLite: Some kind of disk I/O error occurred. | 377| 14800029 | SQLite: The database is full. | 378| 14800030 | SQLite: Unable to open the database file. | 379| 14800031 | SQLite: TEXT or BLOB exceeds size limit. | 380| 14800032 | SQLite: Abort due to constraint violation. | 381| 14800033 | SQLite: Data type mismatch. | 382| 14800034 | SQLite: Library used incorrectly. | 383| 14800047 | The WAL file size exceeds the default limit. | 384 385**Example** 386 387```ts 388import { dataSharePredicates } from '@kit.ArkData'; 389import { BusinessError } from '@kit.BasicServicesKit'; 390 391let predicates = new dataSharePredicates.DataSharePredicates(); 392predicates.equalTo("NAME", "Lisa"); 393if(store != undefined) { 394 (store as relationalStore.RdbStore).delete("EMPLOYEE", predicates).then((rows: Number) => { 395 console.info(`Delete rows: ${rows}`); 396 }).catch((err: BusinessError) => { 397 console.error(`Delete failed, code is ${err.code},message is ${err.message}`); 398 }) 399} 400``` 401 402### query<sup>10+</sup> 403 404query(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<ResultSet>):void 405 406Queries data from the RDB store based on specified conditions. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail. 407 408**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 409 410**Model restriction**: This API can be used only in the stage model. 411 412**System API**: This is a system API. 413 414**Parameters** 415 416| Name | Type | Mandatory| Description | 417| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | 418| table | string | Yes | Name of the target table. | 419| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Query conditions specified by the **DataSharePredicates** object. | 420| callback | AsyncCallback<[ResultSet](#resultset)> | Yes | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.| 421 422**Error codes** 423 424For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 425 426| **ID**| **Error Message** | 427|-----------| ------------------ | 428| 202 | Permission verification failed, application which is not a system application uses system API. | 429| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 430| 14800000 | Inner error. | 431| 14800014 | Already closed. | 432| 14800015 | The database does not respond. | 433 434**Example** 435 436```ts 437import { dataSharePredicates } from '@kit.ArkData'; 438 439let predicates = new dataSharePredicates.DataSharePredicates(); 440predicates.equalTo("NAME", "Rose"); 441if(store != undefined) { 442 (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, (err, resultSet) => { 443 if (err) { 444 console.error(`Query failed, code is ${err.code},message is ${err.message}`); 445 return; 446 } 447 console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); 448 // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. 449 while (resultSet.goToNextRow()) { 450 const id = resultSet.getLong(resultSet.getColumnIndex("ID")); 451 const name = resultSet.getString(resultSet.getColumnIndex("NAME")); 452 const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); 453 const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); 454 console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); 455 } 456 // Release the dataset memory. 457 resultSet.close(); 458 }) 459} 460``` 461 462### query 463 464query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void 465 466Queries data from the RDB store based on specified conditions. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail. 467 468**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 469 470**Model restriction**: This API can be used only in the stage model. 471 472**System API**: This is a system API. 473 474**Parameters** 475 476| Name | Type | Mandatory| Description | 477| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | 478| table | string | Yes | Name of the target table. | 479| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Query conditions specified by the **DataSharePredicates** object. | 480| columns | Array<string> | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. | 481| callback | AsyncCallback<[ResultSet](#resultset)> | Yes | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.| 482 483**Error codes** 484 485For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 486 487| **ID**| **Error Message** | 488|-----------| --------------- | 489| 202 | Permission verification failed, application which is not a system application uses system API. | 490| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 491| 14800000 | Inner error. | 492| 14800014 | Already closed. | 493| 14800015 | The database does not respond. | 494 495**Example** 496 497```ts 498import { dataSharePredicates } from '@kit.ArkData'; 499 500let predicates = new dataSharePredicates.DataSharePredicates(); 501predicates.equalTo("NAME", "Rose"); 502if(store != undefined) { 503 (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], (err, resultSet) => { 504 if (err) { 505 console.error(`Query failed, code is ${err.code},message is ${err.message}`); 506 return; 507 } 508 console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); 509 // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. 510 while (resultSet.goToNextRow()) { 511 const id = resultSet.getLong(resultSet.getColumnIndex("ID")); 512 const name = resultSet.getString(resultSet.getColumnIndex("NAME")); 513 const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); 514 const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); 515 console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); 516 } 517 // Release the dataset memory. 518 resultSet.close(); 519 }) 520} 521``` 522 523### query 524 525query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array<string>):Promise<ResultSet> 526 527Queries data from the RDB store based on specified conditions. This API uses a promise to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail. 528 529**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 530 531**Model restriction**: This API can be used only in the stage model. 532 533**System API**: This is a system API. 534 535**Parameters** 536 537| Name | Type | Mandatory| Description | 538| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ | 539| table | string | Yes | Name of the target table. | 540| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Query conditions specified by the **DataSharePredicates** object. | 541| columns | Array<string> | No | Columns to query. If this parameter is not specified, the query applies to all columns.| 542 543**Return value** 544 545| Type | Description | 546| ------------------------------------------------------- | -------------------------------------------------- | 547| Promise<[ResultSet](#resultset)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| 548 549**Error codes** 550 551For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 552 553| **ID**| **Error Message** | 554|-----------| ----------- | 555| 202 | Permission verification failed, application which is not a system application uses system API. | 556| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 557| 14800000 | Inner error. | 558| 14800014 | Already closed. | 559| 14800015 | The database does not respond. | 560 561**Example** 562 563```ts 564import { dataSharePredicates } from '@kit.ArkData'; 565import { BusinessError } from '@kit.BasicServicesKit'; 566 567let predicates = new dataSharePredicates.DataSharePredicates(); 568predicates.equalTo("NAME", "Rose"); 569if(store != undefined) { 570 (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => { 571 console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); 572 // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. 573 while (resultSet.goToNextRow()) { 574 const id = resultSet.getLong(resultSet.getColumnIndex("ID")); 575 const name = resultSet.getString(resultSet.getColumnIndex("NAME")); 576 const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); 577 const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); 578 console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); 579 } 580 // Release the dataset memory. 581 resultSet.close(); 582 }).catch((err: BusinessError) => { 583 console.error(`Query failed, code is ${err.code},message is ${err.message}`); 584 }) 585} 586``` 587 588### cloudSync<sup>11+</sup> 589 590cloudSync(mode: SyncMode, predicates: RdbPredicates, progress: Callback<ProgressDetails>, callback: AsyncCallback<void>): void 591 592Manually performs device-cloud sync based on specified conditions. This API uses an asynchronous callback to return the result. The cloud sync function must be implemented. Otherwise, this API cannot be used. 593 594**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client 595 596**System API**: This is a system API. 597 598**Parameters** 599 600| Name | Type | Mandatory| Description | 601|-------------|--------------------------------| ---- |-------------------------------| 602| mode | [SyncMode](js-apis-data-relationalStore.md#syncmode) | Yes | Sync mode of the database. | 603| predicates | [RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | Yes | Conditions for data sync. | 604| progress | Callback<[ProgressDetails](js-apis-data-relationalStore.md#progressdetails10)> | Yes | Callback used to process database sync details. | 605| callback | AsyncCallback<void> | Yes | Callback used to return the sync result to the caller.| 606 607**Error codes** 608 609For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 610 611| **ID**| **Error Message** | 612|-----------|--------------| 613| 202 | if permission verification failed, application which is not a system application uses system API. | 614| 401 | Parameter error. Possible causes: 1. Need 2 - 4 parameter(s). 2. The RdbStore must be not nullptr. 3. The mode must be a SyncMode of cloud. 4. The tablesNames must be not empty. 5. The progress must be a callback type. 6.The callback must be a function.| 615| 801 | Capability not supported. | 616| 14800014 | Already closed. | 617 618**Example** 619 620```ts 621let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); 622predicates.in("id", ["id1", "id2"]); 623 624if(store != undefined) { 625 (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, predicates, (progressDetail: relationalStore.ProgressDetails) => { 626 console.info(`progress: ${progressDetail}`); 627 }, (err) => { 628 if (err) { 629 console.error(`cloudSync failed, code is ${err.code},message is ${err.message}}`); 630 return; 631 } 632 console.info('Cloud sync succeeded'); 633 }); 634}; 635``` 636 637### cloudSync<sup>11+</sup> 638 639cloudSync(mode: SyncMode, predicates: RdbPredicates, progress: Callback<ProgressDetails>): Promise<void> 640 641Manually performs device-cloud sync based on specified conditions. This API uses a promise to return the result. The cloud sync function must be implemented. Otherwise, this API cannot be used. 642 643**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client 644 645**System API**: This is a system API. 646 647**Parameters** 648 649| Name | Type | Mandatory| Description | 650|------------|---------------------------------| ---- |---------------------| 651| mode | [SyncMode](js-apis-data-relationalStore.md#syncmode) | Yes | Sync mode of the database. | 652| predicates | [RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | Yes | Conditions for data sync. | 653| progress | Callback<[ProgressDetails](js-apis-data-relationalStore.md#progressdetails10)> | Yes | Callback used to process database sync details.| 654 655**Return value** 656 657| Type | Description | 658| ------------------- | --------------------------------------- | 659| Promise<void> | Promise used to return the sync result.| 660 661**Error codes** 662 663For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 664 665| **ID**| **Error Message** | 666|-----------|---------------------------| 667| 202 | if permission verification failed, application which is not a system application uses system API. | 668| 401 | Parameter error. Possible causes: 1. Need 2 - 4 parameter(s). 2. The RdbStore must be not nullptr. 3. The mode must be a SyncMode of cloud. 4. The tablesNames must be not empty. 5. The progress must be a callback type. | 669| 801 | Capability not supported. | 670| 14800014 | Already closed. | 671 672**Example** 673 674```ts 675import { BusinessError } from '@kit.BasicServicesKit'; 676 677let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); 678predicates.in("id", ["id1", "id2"]); 679 680if(store != undefined) { 681 (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, predicates, (progressDetail: relationalStore.ProgressDetails) => { 682 console.info(`progress: ${progressDetail}`); 683 }).then(() => { 684 console.info('Cloud sync succeeded'); 685 }).catch((err: BusinessError) => { 686 console.error(`cloudSync failed, code is ${err.code},message is ${err.message}}`); 687 }); 688}; 689``` 690 691### querySharingResource<sup>11+</sup> 692 693querySharingResource(predicates: RdbPredicates, columns?: Array<string>): Promise<ResultSet> 694 695Queries the shared resource of the data matching the specified conditions. This API uses a promise to return the result set, which includes the shared resource ID and the column names if the column names are specified. 696 697**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client 698 699**System API**: This is a system API. 700 701**Parameters** 702 703| Name | Type | Mandatory| Description | 704| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- | 705| predicates | [RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | Yes | Query conditions. | 706| columns | Array<string> | No | Columns to be searched for. If this parameter is not specified, the returned result set contains only the shared resource ID.| 707 708**Return value** 709 710| Name | Description | 711| -------- | ------------------------------------------------- | 712| Promise<[ResultSet](#resultset)> | Promise used to return the result set. | 713 714**Error codes** 715 716For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 717 718| **ID**| **Error Message** | 719|-----------|-------------| 720| 401 | Parameter error. Possible causes: 1. Need 1 - 3 parameter(s)! 2. The RdbStore must be not nullptr. 3. The predicates must be an RdbPredicates. 4. The columns must be a string array. | 721| 801 | Capability not supported. | 722| 14800000 | Inner error. | 723| 14800011 | Database corrupted. | 724| 14800014 | Already closed. | 725| 14800015 | The database does not respond. | 726| 14800021 | SQLite: Generic error. | 727| 14800022 | SQLite: Callback routine requested an abort. | 728| 14800023 | SQLite: Access permission denied. | 729| 14800024 | SQLite: The database file is locked. | 730| 14800025 | SQLite: A table in the database is locked. | 731| 14800026 | SQLite: The database is out of memory. | 732| 14800027 | SQLite: Attempt to write a readonly database. | 733| 14800028 | SQLite: Some kind of disk I/O error occurred. | 734| 14800029 | SQLite: The database is full. | 735| 14800030 | SQLite: Unable to open the database file. | 736| 14800031 | SQLite: TEXT or BLOB exceeds size limit. | 737| 14800032 | SQLite: Abort due to constraint violation. | 738| 14800033 | SQLite: Data type mismatch. | 739| 14800034 | SQLite: Library used incorrectly. | 740 741**Example** 742 743```ts 744import { BusinessError } from '@kit.BasicServicesKit'; 745 746let sharingResource: string; 747let predicates = new relationalStore.RdbPredicates('test_table'); 748predicates.equalTo('data', 'data_test'); 749if(store != undefined) { 750 (store as relationalStore.RdbStore).querySharingResource(predicates, ['uuid', 'data']).then((resultSet) => { 751 if (!resultSet.goToFirstRow()) { 752 console.error(`resultSet error`); 753 return; 754 } 755 const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD)); 756 console.info(`sharing resource: ${res}`); 757 sharingResource = res; 758 }).catch((err: BusinessError) => { 759 console.error(`query sharing resource failed, code is ${err.code},message is ${err.message}`); 760 }) 761} 762 763``` 764 765### querySharingResource<sup>11+</sup> 766 767querySharingResource(predicates: RdbPredicates, callback: AsyncCallback<ResultSet>): void 768 769Queries the shared resource of the data matching the specified conditions. This API uses an asynchronous callback to return the result set. 770 771**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client 772 773**System API**: This is a system API. 774 775**Parameters** 776 777| Name | Type | Mandatory| Description | 778| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- | 779| predicates | [RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | Yes | Query conditions. | 780| callback | AsyncCallback<[ResultSet](#resultset)> | Yes | Callback used to return the result set.| 781 782**Error codes** 783 784For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 785 786| **ID**| **Error Message** | 787|-----------|------| 788| 401 | Parameter error. Possible causes: 1. Need 1 - 3 parameter(s)! 2. The RdbStore must be not nullptr. 3. The predicates must be an RdbPredicates. 4. The columns must be a string array. | 789| 801 | Capability not supported. | 790| 14800000 | Inner error. | 791| 14800011 | Database corrupted. | 792| 14800014 | Already closed. | 793| 14800015 | The database does not respond. | 794| 14800021 | SQLite: Generic error. | 795| 14800022 | SQLite: Callback routine requested an abort. | 796| 14800023 | SQLite: Access permission denied. | 797| 14800024 | SQLite: The database file is locked. | 798| 14800025 | SQLite: A table in the database is locked. | 799| 14800026 | SQLite: The database is out of memory. | 800| 14800027 | SQLite: Attempt to write a readonly database. | 801| 14800028 | SQLite: Some kind of disk I/O error occurred. | 802| 14800029 | SQLite: The database is full. | 803| 14800030 | SQLite: Unable to open the database file. | 804| 14800031 | SQLite: TEXT or BLOB exceeds size limit. | 805| 14800032 | SQLite: Abort due to constraint violation. | 806| 14800033 | SQLite: Data type mismatch. | 807| 14800034 | SQLite: Library used incorrectly. | 808 809 810**Example** 811 812```ts 813let sharingResource: string; 814let predicates = new relationalStore.RdbPredicates('test_table'); 815predicates.equalTo('data', 'data_test'); 816if(store != undefined) { 817 (store as relationalStore.RdbStore).querySharingResource(predicates,(err, resultSet) => { 818 if (err) { 819 console.error(`sharing resource failed, code is ${err.code},message is ${err.message}`); 820 return; 821 } 822 if (!resultSet.goToFirstRow()) { 823 console.error(`resultSet error`); 824 return; 825 } 826 const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD)); 827 console.info(`sharing resource: ${res}`); 828 sharingResource = res; 829 }) 830} 831 832``` 833 834### querySharingResource<sup>11+</sup> 835 836querySharingResource(predicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>): void 837 838Queries the shared resource of the data matching the specified conditions. This API uses an asynchronous callback to return the shared resource ID and the column names specified. 839 840**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client 841 842**System API**: This is a system API. 843 844**Parameters** 845 846| Name | Type | Mandatory| Description | 847| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- | 848| predicates | [RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | Yes | Query conditions. | 849| columns | Array<string> | Yes | Columns to be searched for. | 850| callback | AsyncCallback<[ResultSet](#resultset)> | Yes | Callback used to return the result set.| 851 852**Error codes** 853 854For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 855 856| **ID**| **Error Message** | 857|-----------|--------------| 858| 401 | Parameter error. Possible causes: 1. Need 1 - 3 parameter(s)! 2. The RdbStore must be not nullptr. 3. The predicates must be an RdbPredicates. 4. The columns must be a string array. | 859| 801 | Capability not supported. | 860| 14800000 | Inner error. | 861| 14800011 | Database corrupted. | 862| 14800014 | Already closed. | 863| 14800015 | The database does not respond. | 864| 14800021 | SQLite: Generic error. | 865| 14800022 | SQLite: Callback routine requested an abort. | 866| 14800023 | SQLite: Access permission denied. | 867| 14800024 | SQLite: The database file is locked. | 868| 14800025 | SQLite: A table in the database is locked. | 869| 14800026 | SQLite: The database is out of memory. | 870| 14800027 | SQLite: Attempt to write a readonly database. | 871| 14800028 | SQLite: Some kind of disk I/O error occurred. | 872| 14800029 | SQLite: The database is full. | 873| 14800030 | SQLite: Unable to open the database file. | 874| 14800031 | SQLite: TEXT or BLOB exceeds size limit. | 875| 14800032 | SQLite: Abort due to constraint violation. | 876| 14800033 | SQLite: Data type mismatch. | 877| 14800034 | SQLite: Library used incorrectly. | 878 879 880**Example** 881 882```ts 883let sharingResource: string; 884let predicates = new relationalStore.RdbPredicates('test_table'); 885predicates.equalTo('data', 'data_test'); 886if(store != undefined) { 887 (store as relationalStore.RdbStore).querySharingResource(predicates, ['uuid', 'data'], (err, resultSet) => { 888 if (err) { 889 console.error(`sharing resource failed, code is ${err.code},message is ${err.message}`); 890 return; 891 } 892 if (!resultSet.goToFirstRow()) { 893 console.error(`resultSet error`); 894 return; 895 } 896 const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD)); 897 console.info(`sharing resource: ${res}`); 898 sharingResource = res; 899 }) 900} 901 902``` 903 904 905### lockCloudContainer<sup>12+</sup> 906 907lockCloudContainer(): Promise<number> 908 909Manually locks the cloud database of an application. This API uses a promise to return the result. 910 911> **NOTE** 912> 913> After the cloud database is locked, data of the same application logged in with the same account on other devices cannot be synced to the cloud. The cloud sync function must be implemented. Otherwise, this API cannot be used. 914 915**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 916 917**System API**: This is a system API. 918 919**Return value** 920 921| Type | Description | 922| ------------------- | ---------------------------------------| 923| Promise<number> | Promise used to return the lock validity period (in ms) if the operation is successful. If the operation fails, **0** is returned.| 924 925**Error codes** 926 927For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 928 929| **ID**| **Error Message** | 930|-----------|---------------------------| 931| 202 | Permission verification failed, application which is not a system application uses system API. | 932 933**Example** 934 935```ts 936import { BusinessError } from '@kit.BasicServicesKit'; 937 938if(store != undefined) { 939 (store as relationalStore.RdbStore).lockCloudContainer().then((time: Number) => { 940 console.info('lockCloudContainer succeeded time:' + time); 941 }).catch((err: BusinessError) => { 942 console.error(`lockCloudContainer failed, code is ${err.code},message is ${err.message}`); 943 }) 944} 945``` 946 947### unlockCloudContainer<sup>12+</sup> 948 949unlockCloudContainer(): Promise<void> 950 951Manually unlocks the cloud database of an application. This API uses a promise to return the result. The cloud sync function must be implemented. Otherwise, this API cannot be used. 952 953**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 954 955**System API**: This is a system API. 956 957**Return value** 958 959| Type | Description | 960| ------------------- | --------------------------------------- | 961| Promise<void> | Promise that returns no value.| 962 963**Error codes** 964 965For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 966 967| **ID**| **Error Message** | 968|-----------|---------------------------| 969| 202 | Permission verification failed, application which is not a system application uses system API. | 970 971**Example** 972 973```ts 974import { BusinessError } from '@kit.BasicServicesKit'; 975 976if(store != undefined) { 977 (store as relationalStore.RdbStore).unlockCloudContainer().then(() => { 978 console.info('unlockCloudContainer succeeded'); 979 }).catch((err: BusinessError) => { 980 console.error(`unlockCloudContainer failed, code is ${err.code},message is ${err.message}`); 981 }) 982} 983``` 984 985### restore<sup>12+</sup> 986 987restore(): Promise<void> 988 989Restores data from a replica RDB store file. This API uses a promise to return the result. This API can be used only when [HAMode](#hamode12) is **MAIN_REPLICA**, and cannot be used in transactions. 990 991**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 992 993**System API**: This is a system API. 994 995**Return value** 996 997| Type | Description | 998| ------------------- | ------------------------- | 999| Promise<void> | Promise that returns no value.| 1000 1001**Error codes** 1002 1003For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 1004 1005| **ID**| **Error Message** | 1006|-----------| ------------------------------------------------------------ | 1007| 202 | Permission verification failed, application which is not a system application uses system API. | 1008| 14800000 | Inner error. | 1009| 14800010 | Invalid database path. | 1010| 14800011 | Database corrupted. | 1011| 14800014 | Already closed. | 1012| 14800015 | The database does not respond. | 1013| 14800021 | SQLite: Generic error. | 1014| 14800022 | SQLite: Callback routine requested an abort. | 1015| 14800023 | SQLite: Access permission denied. | 1016| 14800024 | SQLite: The database file is locked. | 1017| 14800025 | SQLite: A table in the database is locked. | 1018| 14800026 | SQLite: The database is out of memory. | 1019| 14800027 | SQLite: Attempt to write a readonly database. | 1020| 14800028 | SQLite: Some kind of disk I/O error occurred. | 1021| 14800029 | SQLite: The database is full. | 1022| 14800030 | SQLite: Unable to open the database file. | 1023| 14800031 | SQLite: TEXT or BLOB exceeds size limit. | 1024| 14800032 | SQLite: Abort due to constraint violation. | 1025| 14800033 | SQLite: Data type mismatch. | 1026| 14800034 | SQLite: Library used incorrectly. | 1027 1028**Example** 1029 1030```ts 1031import { BusinessError } from '@kit.BasicServicesKit'; 1032 1033let store: relationalStore.RdbStore | undefined = undefined; 1034if(store != undefined) { 1035 let promiseRestore = (store as relationalStore.RdbStore).restore(); 1036 promiseRestore.then(() => { 1037 console.info('Succeeded in restoring.'); 1038 }).catch((err: BusinessError) => { 1039 console.error(`Failed to restore, code is ${err.code},message is ${err.message}`); 1040 }) 1041} 1042``` 1043 1044## ResultSet 1045 1046Provides APIs to access the **resultSet** object returned by **query()**. 1047 1048### getFloat32Array<sup>12+</sup> 1049 1050getFloat32Array(columnIndex: number): Float32Array 1051 1052Obtains the value from the specified column in the current row and outputs it in a Float32Array (array of 32-bit floating-point numbers). This API is available only for a [vector database](#storeconfig). 1053 1054**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 1055 1056**Parameters** 1057 1058| Name | Type | Mandatory| Description | 1059| ----------- | ------ | ---- | ----------------------- | 1060| columnIndex | number | Yes | Index of the target column, starting from 0.| 1061 1062**Return value** 1063 1064| Type | Description | 1065| ---------- | -------------------------------- | 1066| Float32Array | Value obtained, in a Float32Array.| 1067 1068**Error codes** 1069 1070For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). 1071 1072| **ID**| **Error Message** | 1073|-----------| ------------ | 1074| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 1075| 801 | The capability is not supported because the database is not a vector DB. | 1076| 14800011 | Database corrupted. | 1077| 14800013 | Column out of bounds. | 1078| 14800014 | Already closed. | 1079| 14800021 | SQLite: Generic error. | 1080| 14800022 | SQLite: Callback routine requested an abort. | 1081| 14800023 | SQLite: Access permission denied. | 1082| 14800024 | SQLite: The database file is locked. | 1083| 14800025 | SQLite: A table in the database is locked. | 1084| 14800026 | SQLite: The database is out of memory. | 1085| 14800027 | SQLite: Attempt to write a readonly database. | 1086| 14800028 | SQLite: Some kind of disk I/O error occurred. | 1087| 14800029 | SQLite: The database is full. | 1088| 14800030 | SQLite: Unable to open the database file. | 1089| 14800031 | SQLite: TEXT or BLOB exceeds size limit. | 1090| 14800032 | SQLite: Abort due to constraint violation. | 1091| 14800033 | SQLite: Data type mismatch. | 1092| 14800034 | SQLite: Library used incorrectly. | 1093 1094**Example** 1095 1096```ts 1097let resultSet: relationalStore.ResultSet | undefined; 1098if(resultSet != undefined) { 1099 const id = (resultSet as relationalStore.ResultSet).getFloat32Array(0); 1100} 1101``` 1102