Interface (ResultSet)

Provides APIs to access the result set obtained by querying the RDB store. This result set is the collection of results returned with the query() method called.

The ResultSet instance is not refreshed in real time. After using the result set, if the data in the database is changed (by being added, deleted, or modified), you need to query the result set again to obtain the latest data.

For the following APIs, you should use either query, querySql, remoteQuery, or queryLockedRow to obtain the ResultSet instance first, and then use this instance to call the corresponding method.

NOTE

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.

Module to Import

import { relationalStore } from '@kit.ArkData';

Properties

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Name Type Read-Only Optional Description
columnNames Array<string> Yes No Names of all columns in the result set. If the result set contains duplicate column names, the return values are not as expected. You are advised to use the getColumnNames API to obtain the column names.
columnCount number Yes No Number of columns in the result set.
rowCount number Yes No Number of rows in the result set.
rowIndex number Yes No Index of the current row in the result set.
Default value: -1. The index position starts from 0.
isAtFirstRow boolean Yes No Whether the result set pointer is in the first row (the row index is 0). The value true means the result set pointer is in the first row.
isAtLastRow boolean Yes No Whether the result set pointer is in the last row. The value true means the pointer is in the last row.
isEnded boolean Yes No Whether the result set pointer is after the last row. The value true means the pointer is after the last row.
isStarted boolean Yes No Whether the result set pointer is moved. The value true means the pointer is moved.
isClosed boolean Yes No Whether the result set is closed. The value true means the result set is closed.

getColumnNames23+

getColumnNames(): Array<string>

Obtains the names of all columns in the result set.

The column names are returned in a string array. The sequence of strings in the array is the same as that of columns in the result set.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Return value

Type Description
Array<string> Names of all columns in the result set obtained. Duplicate column names can be obtained.

Error codes

For details about the error codes, see RDB Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
14800001 Invalid arguments. Possible causes: 1. Parameter is out of valid range.
14800011 The current operation failed because the database is corrupted.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800026 SQLite: The database is out of memory.
14800028 SQLite: Some kind of disk I/O error occurred.
14800030 SQLite: Unable to open the database file.

Example:

try {
  // Query EMPLOYEE1 and EMPLOYEE2 and obtain the duplicate column names. store is the obtained RdbStore instance.
  let resultSet: relationalStore.ResultSet = await store.querySql("SELECT e1.NAME, e2.NAME, e1.AGE, e2.AGE FROM EMPLOYEE1 e1 LEFT JOIN EMPLOYEE2 e2 ON e1.SALARY=e2.SALARY");
  if (resultSet != undefined) {
    const names = resultSet.getColumnNames();
  }
} catch (err) {
  console.error(`Failed to get column names: code:${err.code}, message:${err.message}`);
}

getColumnIndex

getColumnIndex(columnName: string): number

Obtains the column index based on the column name.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnName string Yes Column name.

Return value

Type Description
number Column index obtained. If the result set contains duplicate column names, the return value is not as expected.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
  const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
  const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
  const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
}

getColumnName

getColumnName(columnIndex: number): string

Obtains the column name based on the column index.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIndex number Yes Column index.

Return value

Type Description
string Column name obtained. If the result set contains duplicate column names, the return value is not as expected.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  const id = (resultSet as relationalStore.ResultSet).getColumnName(0);
  const name = (resultSet as relationalStore.ResultSet).getColumnName(1);
  const age = (resultSet as relationalStore.ResultSet).getColumnName(2);
}

getColumnType18+

getColumnType(columnIdentifier: number | string): Promise<ColumnType>

Obtains the column type based on the specified column index or column name. This API uses a promise to return the result.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIdentifier number | string Yes Index or name of column in a result set. The index must be a non-negative integer and cannot exceed the length of columnNames. The column name must be a name in columnNames.

Return value

Type Description
Promise<ColumnType> Promise used to return the column type obtained. If the result set contains duplicate column names, the return value is not as expected.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  let idType = await (resultSet as relationalStore.ResultSet).getColumnType("ID") as relationalStore.ColumnType;
  let nameType = await (resultSet as relationalStore.ResultSet).getColumnType("NAME") as relationalStore.ColumnType;
  let ageType = await (resultSet as relationalStore.ResultSet).getColumnType("AGE") as relationalStore.ColumnType;
  let salaryType = await (resultSet as relationalStore.ResultSet).getColumnType("SALARY") as relationalStore.ColumnType;
  let codesType = await (resultSet as relationalStore.ResultSet).getColumnType("CODES") as relationalStore.ColumnType;
  let identityType = await (resultSet as relationalStore.ResultSet).getColumnType(5) as relationalStore.ColumnType;
  let assetDataType = await (resultSet as relationalStore.ResultSet).getColumnType(6) as relationalStore.ColumnType;
  let assetsDataType = await (resultSet as relationalStore.ResultSet).getColumnType(7) as relationalStore.ColumnType;
  let floatArrayType = await (resultSet as relationalStore.ResultSet).getColumnType(8) as relationalStore.ColumnType;
}

getColumnTypeSync18+

getColumnTypeSync(columnIdentifier: number | string): ColumnType

Obtains the column type based on the specified column index or column name. This API returns the result synchronously.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIdentifier number | string Yes Index or name of column in a result set. The index must be a non-negative integer and cannot exceed the length of columnNames. The column name must be a name in columnNames.

Return value

Type Description
ColumnType Column type obtained. If the result set contains duplicate column names, the return value is not as expected.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  let idType = (resultSet as relationalStore.ResultSet).getColumnTypeSync("ID") as relationalStore.ColumnType;
  let nameType = (resultSet as relationalStore.ResultSet).getColumnTypeSync("NAME") as relationalStore.ColumnType;
  let ageType = (resultSet as relationalStore.ResultSet).getColumnTypeSync("AGE") as relationalStore.ColumnType;
  let salaryType = (resultSet as relationalStore.ResultSet).getColumnTypeSync("SALARY") as relationalStore.ColumnType;
  let codesType = (resultSet as relationalStore.ResultSet).getColumnTypeSync("CODES") as relationalStore.ColumnType;
  let identityType = (resultSet as relationalStore.ResultSet).getColumnTypeSync(5) as relationalStore.ColumnType;
  let assetDataType = (resultSet as relationalStore.ResultSet).getColumnTypeSync(6) as relationalStore.ColumnType;
  let assetsDataType = (resultSet as relationalStore.ResultSet).getColumnTypeSync(7) as relationalStore.ColumnType;
  let floatArrayType = (resultSet as relationalStore.ResultSet).getColumnTypeSync(8) as relationalStore.ColumnType;
}

goTo

goTo(offset:number): boolean

Moves the result set pointer based on the offset specified.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
offset number Yes Offset relative to the position of the current result set pointer. A positive value means to move the pointer backward, and a negative value means to move the pointer forward.

Return value

Type Description
boolean Returns true if the operation is successful; returns false otherwise.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  (resultSet as relationalStore.ResultSet).goTo(1);
}

goToRow

goToRow(position: number): boolean

Moves to the specified row in the result set.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
position number Yes Destination position to move to.

Return value

Type Description
boolean Returns true if the operation is successful; returns false otherwise.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  (resultSet as relationalStore.ResultSet).goToRow(5);
}

goToFirstRow

goToFirstRow(): boolean

Moves to the first row of the result set.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Return value

Type Description
boolean Returns true if the operation is successful; returns false otherwise.

Error codes

For details about the error codes, see RDB Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  (resultSet as relationalStore.ResultSet).goToFirstRow();
}

goToLastRow

goToLastRow(): boolean

Moves to the last row of the result set.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Return value

Type Description
boolean Returns true if the operation is successful; returns false otherwise.

Error codes

For details about the error codes, see RDB Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  (resultSet as relationalStore.ResultSet).goToLastRow();
}

goToNextRow

goToNextRow(): boolean

Moves to the next row in the result set.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Return value

Type Description
boolean Returns true if the operation is successful; returns false otherwise.

Error codes

For details about the error codes, see RDB Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  (resultSet as relationalStore.ResultSet).goToNextRow();
}

goToPreviousRow

goToPreviousRow(): boolean

Moves to the previous row in the result set.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Return value

Type Description
boolean Returns true if the operation is successful; returns false otherwise.

Error codes

For details about the error codes, see RDB Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  (resultSet as relationalStore.ResultSet).goToPreviousRow();
}

getValue12+

getValue(columnIndex: number): ValueType

Obtains the value from the specified column in the current row. If the value type is any of ValueType, the value of the corresponding type will be returned. Otherwise, 14800000 will be returned. If the value type is INTEGER and the value is greater than Number.MAX_SAFE_INTEGER or less than Number.MIN_SAFE_INTEGER, you are advised to use the getString API to obtain the value without losing precision.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIndex number Yes Index of the target column, starting from 0.

Return value

Type Description
ValueType Allowed data field types.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet !== undefined) {
  while (resultSet.goToNextRow()) {
    const colIndex = resultSet.getColumnIndex("NAME");
    if (colIndex > -1) {
      const name = resultSet.getValue(colIndex);
      console.info(`Get value success, name is ${name}`);
    }
  }
}

getBlob

getBlob(columnIndex: number): Uint8Array

Obtains the value from the specified column in the current row, and returns it in a byte array.
If the type of the value in the specified column is INTEGER, DOUBLE, TEXT, or BLOB, the value will be converted into a byte array and returned. If the column is null/empty, an empty byte array will be returned. If the value is of any other type, 14800000 will be returned.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIndex number Yes Index of the target column, starting from 0.

Return value

Type Description
Uint8Array Value obtained.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  const codes = (resultSet as relationalStore.ResultSet).getBlob((resultSet as relationalStore.ResultSet).getColumnIndex("CODES"));
}

getString

getString(columnIndex: number): string

Obtains the value from the specified column in the current row, and returns it in the form of a string.
If the type of the value in the specified column is INTEGER, DOUBLE, TEXT, or BLOB, a string will be returned. If the value type is INTEGER and the column is null/empty, an empty string "" will be returned. If the value is of any other type, 14800000 will be returned. If the value in the current column is of the DOUBLE type, the precision may be lost. You are advised to use getDouble to obtain the value.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIndex number Yes Index of the target column, starting from 0.

Return value

Type Description
string Value obtained.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
}

getLong

getLong(columnIndex: number): number

Obtains the value from the specified column in the current row, and returns a value of Long type.
If the type of the value in the specified column is INTEGER, DOUBLE, TEXT, or BLOB, a value of Long type will be returned. If the column is null/empty, 0 will be returned. If the value is of any other type, 14800000 will be returned. If the data type in the specified column is INTEGER and the value is greater than Number.MAX_SAFE_INTEGER or less than Number.MIN_SAFE_INTEGER, you are advised to use the getString API to obtain the value without losing precision. If the data type in the specified column is DOUBLE, you are advised to use the getDouble API to obtain the value without losing precision.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIndex number Yes Index of the target column, starting from 0.

Return value

Type Description
number Value obtained.
The value range supported by this API is Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER. If the value is out of this range, use getDouble for DOUBLE values and getString for INTEGER values.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet !== undefined) {
  while (resultSet.goToNextRow()) {
    const colIndex = resultSet.getColumnIndex("AGE");
    if (colIndex > -1) {
      const age = resultSet.getLong(colIndex);
      console.info(`Get long success, age is ${age}`);
    }
  }
}

getDouble

getDouble(columnIndex: number): number

Obtains the value from the specified column in the current row, and returns a value of Double type.
If the type of the value in the specified column is INTEGER, DOUBLE, TEXT, or BLOB, a value of Double type will be returned. If the column is null/empty, 0.0 will be returned. If the value is of any other type, 14800000 will be returned.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIndex number Yes Index of the target column, starting from 0.

Return value

Type Description
number Value obtained.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet !== undefined) {
  while (resultSet.goToNextRow()) {
    const colIndex = resultSet.getColumnIndex("SALARY");
    if (colIndex > -1) {
      const salary = resultSet.getDouble(colIndex);
      console.info(`Get double success, salary is ${salary}`);
    }
  }
}

getAsset10+

getAsset(columnIndex: number): Asset

Obtains the value from the specified column in the current row, and returns the value in the Asset format. If the type of the value in the column is Asset, the value of the Asset type is returned. If the value in the column is null, null is returned. If the value in the column is of other types, 14800000 is returned.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIndex number Yes Index of the target column, starting from 0.

Return value

Type Description
Asset Value obtained.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  const doc = (resultSet as relationalStore.ResultSet).getAsset((resultSet as relationalStore.ResultSet).getColumnIndex("DOC"));
}

getAssets10+

getAssets(columnIndex: number): Assets

Obtains the value from the specified column in the current row, and returns the value in the Assets format. If the type of the value in the column is Assets, the value of the Assets type is returned. If the value in the column is null, null is returned. If the value in the column is of other types, 14800000 is returned.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIndex number Yes Index of the target column, starting from 0.

Return value

Type Description
Assets Value obtained.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  const docs = (resultSet as relationalStore.ResultSet).getAssets((resultSet as relationalStore.ResultSet).getColumnIndex("DOCS"));
}

getRow11+

getRow(): ValuesBucket

Obtains this row.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Return value

Type Description
ValuesBucket Value of the specified row. If the result set contains duplicate column names, the return value is not as expected. You are advised to use the getCurrentRowData API.

Error codes

For details about the error codes, see RDB Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet != undefined) {
  const row = (resultSet as relationalStore.ResultSet).getRow();
}

getRows18+

getRows(maxCount: number, position?: number): Promise<Array<ValuesBucket>>

Obtains a specified amount of data from the result set. This API uses a promise to return the result. Do not call this API concurrently with other APIs of ResultSet. Otherwise, unexpected data may be obtained.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
maxCount number Yes Number of rows to obtain. The value is a positive integer. If the value is not a positive integer, error 401 will be thrown.
position number No Start position for obtaining data from the result set. The value is a non-negative integer. If this parameter is not specified, data is obtained from the current row of the result set (by default, it is the first row of the result set when data is obtained for the first time). If the value is not a non-negative integer, error code 401 will be thrown.

Return value

Type Description
Promise<Array<ValuesBucket>> Promise used to return maxCount rows of data obtained. If the number of remaining records is less than maxCount, the remaining records are returned. Returning an empty array indicates that the end of the result set is reached. If the result set contains duplicate column names, the return values are not as expected. You are advised to use the getRowsData API.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.

Example:

// Obtain 100 rows of data.
async function processRows(resultSet: relationalStore.ResultSet) {
  // Example 1: Specify only maxCount.
  if (resultSet != undefined) {
    let rows: Array<relationalStore.ValuesBucket>;
    let maxCount: number = 50;
    // Obtain data from the current row of the result set. By default, the first fetch starts from the first row of the current result set. Subsequent fetches start from the row following the last row retrieved.
    // getRows automatically moves the current row of the result set to the row following the last row retrieved by the previous getRows call. You do not need to use APIs such as goToFirstRow and goToNextRow.
    while ((rows = await (resultSet as relationalStore.ResultSet).getRows(maxCount)).length != 0) {
      console.info(JSON.stringify(rows[0]));
    }
  }

  // Example 2: Specify maxCount and position.
  if (resultSet != undefined) {
    let rows: Array<relationalStore.ValuesBucket>;
    let maxCount: number = 50;
    let position: number = 50;
    while ((rows = await (resultSet as relationalStore.ResultSet).getRows(maxCount, position)).length != 0) {
      console.info(JSON.stringify(rows[0]));
      position += rows.length;
    }
  }
}

getCurrentRowData23+

getCurrentRowData(): RowData

Obtains the values of all columns in this row.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Return value

Type Description
RowData Values of all columns in this row obtained. The values of columns with the same name can be obtained.

Error codes

For details about the error codes, see RDB Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
14800001 Invalid arguments. Possible causes: 1. Parameter is out of valid range.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800026 SQLite: The database is out of memory.
14800028 SQLite: Some kind of disk I/O error occurred.
14800030 SQLite: Unable to open the database file.

Example:

try {
  // Query EMPLOYEE1 and EMPLOYEE2 and obtain the values of the current row that contain duplicate column names. store is the obtained RdbStore instance.
  let resultSet: relationalStore.ResultSet = await store.querySql("SELECT e1.NAME, e2.NAME, e1.AGE, e2.AGE FROM EMPLOYEE1 e1 LEFT JOIN EMPLOYEE2 e2 ON e1.SALARY=e2.SALARY");
  if (resultSet != undefined) {
    resultSet.goToFirstRow();
    const rowData = resultSet.getCurrentRowData();
  }
} catch (err) {
  console.error(`Failed to get row data: code:${err.code}, message:${err.message}`);
}

getRowsData23+

getRowsData(maxCount: number, position?: number): Promise<RowsData>

Obtains data of a specified number of rows from the specified position. This API uses a promise to return the result. Do not call this API concurrently with other APIs of ResultSet. Otherwise, unexpected data may be obtained.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
maxCount number Yes Number of rows to obtain. The value is a positive integer. If the value is not a positive integer, error 14800001 will be thrown.
position number No Start position for obtaining data from the result set. The value is a non-negative integer. If this parameter is not specified, data is obtained from the current row of the result set (by default, it is the first row of the result set when data is obtained for the first time). If the value is not a non-negative integer, error code 14800001 will be thrown.

Return value

Type Description
Promise<RowsData> Promise used to return maxCount rows of data obtained. If the number of remaining records is less than maxCount, the remaining records are returned. Returning an empty array indicates that the end of the result set is reached. The values of columns with the same name can be obtained.

Error codes

For details about the error codes, see RDB Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
14800001 Invalid arguments. Possible causes: 1. Parameter is out of valid range.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800014 The target instance is already closed.
14800019 The SQL must be a query statement.
14800021 SQLite: Generic error.
14800026 SQLite: The database is out of memory.
14800028 SQLite: Some kind of disk I/O error occurred.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.

Example:

try {
  // Query EMPLOYEE1 and EMPLOYEE2 and obtain the values of multiple rows that contain duplicate column names. store is the obtained RdbStore instance.
  let resultSet: relationalStore.ResultSet = await store.querySql("SELECT e1.NAME, e2.NAME, e1.AGE, e2.AGE FROM EMPLOYEE1 e1 LEFT JOIN EMPLOYEE2 e2 ON e1.SALARY=e2.SALARY");
  // Obtain 50 rows of data.
  // Example 1: Specify only maxCount.
  if (resultSet != undefined) {
    let rowsData: relationalStore.RowsData;
    // Obtain data from the current row of the result set. By default, the first fetch starts from the first row of the current result set. Subsequent fetches start from the row following the last row retrieved.
    // getRowsData automatically moves the current row of the result set to the next row after the end position of the last retrieval by getRowsData. You do not need to use APIs such as goToFirstRow and goToNextRow.
    let maxCount: number = 50;
    let rowCount: number = 0;
    while ((rowsData = await resultSet.getRowsData(maxCount)).length != 0) {
      rowsData.forEach((rowData, index) => {
        // Query result of the row specified by rowCount + index + 1
        console.info(`${rowCount + index + 1}: ${rowData}`);
      });
      rowCount += rowsData.length;
    }
  }

  // Example 2: Specify maxCount and position.
  if (resultSet != undefined) {
    let rowsData: relationalStore.RowsData;
    let maxCount: number = 50;
    let position: number = 50;
    while ((rowsData = await resultSet.getRowsData(maxCount, position)).length != 0) {
      rowsData.forEach((rowData, index) => {
        // Query result of the row specified by position + index + 1
        console.info(`${position + index + 1}: ${rowData}`);
      });
      position += rowsData.length;
    }
  }
} catch (err) {
  console.error(`Failed to get rows data: code:${err.code}, message:${err.message}`);
}

getSendableRow12+

getSendableRow(): sendableRelationalStore.ValuesBucket

Obtains the sendable data from the current row. The sendable data can be passed across threads.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Return value

Type Description
sendableRelationalStore.ValuesBucket Sendable data obtained for cross-thread transfer.

Error codes

For details about the error codes, see RDB Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

For details about the definition of this.context in the sample code, see the application context of the stage model.

import { window } from '@kit.ArkUI';
import { UIAbility } from '@kit.AbilityKit';
import { relationalStore } from '@kit.ArkData';
import { taskpool } from '@kit.ArkTS';
import { common } from '@kit.AbilityKit';
import { sendableRelationalStore } from '@kit.ArkData';

@Concurrent
async function getDataByName(name: string, context: common.UIAbilityContext) {
  const STORE_CONFIG: relationalStore.StoreConfig = {
    name: "RdbTest.db",
    securityLevel: relationalStore.SecurityLevel.S3
  };
  const store = await relationalStore.getRdbStore(context, STORE_CONFIG);
  const predicates = new relationalStore.RdbPredicates("EMPLOYEE");
  predicates.equalTo("NAME", name);
  const resultSet = store.querySync(predicates);

  if (resultSet.rowCount > 0) {
    resultSet.goToFirstRow();
    const sendableValuesBucket = resultSet.getSendableRow();
    return sendableValuesBucket;
  } else {
    return null;
  }
}

export default class EntryAbility extends UIAbility {
  async onWindowStageCreate(windowStage: window.WindowStage) {
    const task = new taskpool.Task(getDataByName, 'Lisa', this.context);
    const sendableValuesBucket = await taskpool.execute(task) as sendableRelationalStore.ValuesBucket;

    if (sendableValuesBucket) {
      const columnCount = sendableValuesBucket.size;
      const age = sendableValuesBucket.get('age');
      const name = sendableValuesBucket.get('name');
      console.info(`Query data in taskpool succeeded, name is "${name}", age is "${age}"`);
    }
  }
}

isColumnNull

isColumnNull(columnIndex: number): boolean

Checks whether the value in the specified column is null.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Parameters

Name Type Mandatory Description
columnIndex number Yes Index of the target column, starting from 0.

Return value

Type Description
boolean Returns true if the value is null; returns false otherwise.

Error codes

For details about the error codes, see Universal Error Codes and RDB Store Error Codes. For details about how to handle error 14800011, see Database Backup and Restore.

ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
14800000 Inner error.
14800011 The current operation failed because the database is corrupted.
14800012 ResultSet is empty or pointer index is out of bounds.
14800013 Column index is out of bounds.
14800014 The target instance is already closed.
14800021 SQLite: Generic error.
14800022 SQLite: Callback routine requested an abort.
14800023 SQLite: Access permission denied.
14800024 SQLite: The database file is locked.
14800025 SQLite: A table in the database is locked.
14800026 SQLite: The database is out of memory.
14800027 SQLite: Attempt to write a readonly database.
14800028 SQLite: Some kind of disk I/O error occurred.
14800029 SQLite: The database is full.
14800030 SQLite: Unable to open the database file.
14800031 SQLite: TEXT or BLOB exceeds size limit.
14800032 SQLite: Abort due to constraint violation.
14800033 SQLite: Data type mismatch.
14800034 SQLite: Library used incorrectly.

Example:

if (resultSet !== undefined) {
  while (resultSet.goToNextRow()) {
    const colIndex = resultSet.getColumnIndex("CODES");
    if (colIndex > -1) {
      const isColumnNull = resultSet.isColumnNull(colIndex);
      console.info(`Column is null: ${isColumnNull}`);
    }
  }
}

close

close(): void

Closes this resultSet to release memory. If the resultSet is not closed, FD or memory leaks may occur.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Example:

if (resultSet != undefined) {
  (resultSet as relationalStore.ResultSet).close();
}

Error codes

For details about the error codes, see RDB Error Codes.

ID Error Message
14800000 Inner error.
14800012 ResultSet is empty or pointer index is out of bounds.