1e41f4b71Sopenharmony_ci# @ohos.data.dataShareResultSet (DataShare Result Set) (System API)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **DataShareResultSet** module provides APIs for accessing the result set obtained from the database. You can access the values in the specified rows or the value of the specified data type.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - 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.
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> - The APIs provided by this module are system APIs.
10e41f4b71Sopenharmony_ci>
11e41f4b71Sopenharmony_ci> - The APIs of this module can be used only in the stage model.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci## Modules to Import
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci```ts
17e41f4b71Sopenharmony_ciimport { DataShareResultSet } from '@kit.ArkData';
18e41f4b71Sopenharmony_ci```
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci## Usage
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ciYou can use [query](js-apis-data-dataShare-sys.md#query) to obtain a **DataShareResultSet** object.
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci```ts
25e41f4b71Sopenharmony_ciimport { DataShareResultSet, dataShare, dataSharePredicates } from '@kit.ArkData';
26e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'
27e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_cilet dataShareHelper: dataShare.DataShareHelper | undefined = undefined;
30e41f4b71Sopenharmony_cilet uri = ("datashare:///com.samples.datasharetest.DataShare");
31e41f4b71Sopenharmony_cilet context = getContext(UIAbility);
32e41f4b71Sopenharmony_cidataShare.createDataShareHelper(context, uri, (err:BusinessError, data:dataShare.DataShareHelper) => {
33e41f4b71Sopenharmony_ci  if (err != undefined) {
34e41f4b71Sopenharmony_ci    console.error("createDataShareHelper fail, error message : " + err);
35e41f4b71Sopenharmony_ci  } else {
36e41f4b71Sopenharmony_ci    console.info("createDataShareHelper end, data : " + data);
37e41f4b71Sopenharmony_ci    dataShareHelper = data;
38e41f4b71Sopenharmony_ci  }
39e41f4b71Sopenharmony_ci});
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_cilet columns = ["*"];
42e41f4b71Sopenharmony_cilet da = new dataSharePredicates.DataSharePredicates();
43e41f4b71Sopenharmony_cilet resultSet: DataShareResultSet | undefined = undefined;
44e41f4b71Sopenharmony_cida.equalTo("name", "ZhangSan");
45e41f4b71Sopenharmony_ciif (dataShareHelper != undefined) {
46e41f4b71Sopenharmony_ci  (dataShareHelper as dataShare.DataShareHelper).query(uri, da, columns).then((data: DataShareResultSet) => {
47e41f4b71Sopenharmony_ci    console.info("query end, data : " + data);
48e41f4b71Sopenharmony_ci    resultSet = data;
49e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
50e41f4b71Sopenharmony_ci    console.error("query fail, error message : " + err);
51e41f4b71Sopenharmony_ci  });
52e41f4b71Sopenharmony_ci}
53e41f4b71Sopenharmony_ci```
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci## DataShareResultSet
56e41f4b71Sopenharmony_ciProvides APIs for accessing the result sets returned.
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ciThe column or key names are returned as a string array, in which the strings are in the same order as the columns or keys in the result set.
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci### Properties
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci| Name       | Type     | Mandatory| Description                    |
65e41f4b71Sopenharmony_ci| ----------- | ------------- | ---- | ------------------------ |
66e41f4b71Sopenharmony_ci| columnNames | Array<string> | Yes  | Names of all columns in the result set.  |
67e41f4b71Sopenharmony_ci| columnCount | number        | Yes  | Number of columns in the result set.        |
68e41f4b71Sopenharmony_ci| rowCount    | number        | Yes  | Number of rows in the result set.        |
69e41f4b71Sopenharmony_ci| isClosed    | boolean       | Yes  | Whether the result set is closed.|
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci### goToFirstRow
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_cigoToFirstRow(): boolean
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ciMoves to the first row of the result set.
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci**Return value**
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci| Type   | Description                                         |
82e41f4b71Sopenharmony_ci| :------ | --------------------------------------------- |
83e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci**Example**
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci```ts
88e41f4b71Sopenharmony_ci// Create a resultSet object. For details, see Usage in this topic.
89e41f4b71Sopenharmony_ciif (resultSet != undefined) {
90e41f4b71Sopenharmony_ci  let isGoToFirstRow = (resultSet as DataShareResultSet).goToFirstRow();
91e41f4b71Sopenharmony_ci  console.info('resultSet.goToFirstRow: ' + isGoToFirstRow);
92e41f4b71Sopenharmony_ci}
93e41f4b71Sopenharmony_ci```
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci### goToLastRow
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_cigoToLastRow(): boolean
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ciMoves to the last row of the result set.
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci**Return value**
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci| Type| Description|
106e41f4b71Sopenharmony_ci| -------- | -------- |
107e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci**Example**
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci```ts
112e41f4b71Sopenharmony_ciif (resultSet != undefined) {
113e41f4b71Sopenharmony_ci  let isGoToLastRow = (resultSet as DataShareResultSet).goToLastRow();
114e41f4b71Sopenharmony_ci  console.info('resultSet.goToLastRow: ' + isGoToLastRow);
115e41f4b71Sopenharmony_ci}
116e41f4b71Sopenharmony_ci```
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci### goToNextRow
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_cigoToNextRow(): boolean
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ciMoves to the next row in the result set.
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci**Return value**
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci| Type   | Description                                         |
129e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
130e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci**Example**
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci```ts
135e41f4b71Sopenharmony_ciif (resultSet != undefined) {
136e41f4b71Sopenharmony_ci  let isGoToNextRow = (resultSet as DataShareResultSet).goToNextRow();
137e41f4b71Sopenharmony_ci  console.info('resultSet.goToNextRow: ' + isGoToNextRow);
138e41f4b71Sopenharmony_ci}
139e41f4b71Sopenharmony_ci```
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci### goToPreviousRow
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_cigoToPreviousRow(): boolean
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ciMoves to the previous row in the result set.
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci**Return value**
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci| Type   | Description                                         |
152e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
153e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci**Example**
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci```ts
158e41f4b71Sopenharmony_ciif (resultSet != undefined) {
159e41f4b71Sopenharmony_ci  let isGoToPreviousRow = (resultSet as DataShareResultSet).goToPreviousRow();
160e41f4b71Sopenharmony_ci  console.info('resultSet.goToPreviousRow: ' + isGoToPreviousRow);
161e41f4b71Sopenharmony_ci}
162e41f4b71Sopenharmony_ci```
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci### goTo
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_cigoTo(offset: number): boolean
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ciMoves based on the specified offset.
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci**Parameters**
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci| **Name**| **Type**| **Mandatory**| Description                                                        |
175e41f4b71Sopenharmony_ci| ---------- | -------- | -------- | ------------------------------------------------------------ |
176e41f4b71Sopenharmony_ci| offset     | number   | Yes      | Offset relative to the current position. A negative value means to move backward, and a positive value means to move forward.|
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci**Return value**
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci| Type   | Description                                         |
181e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
182e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci**Example**
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci```ts
187e41f4b71Sopenharmony_cilet goToNum = 1;
188e41f4b71Sopenharmony_ciif (resultSet != undefined) {
189e41f4b71Sopenharmony_ci  let isGoTo = (resultSet as DataShareResultSet).goTo(goToNum);
190e41f4b71Sopenharmony_ci  console.info('resultSet.goTo: ' + isGoTo);
191e41f4b71Sopenharmony_ci}
192e41f4b71Sopenharmony_ci```
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci### goToRow
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_cigoToRow(position: number): boolean
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ciMoves to the specified row in the result set.
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci**Parameters**
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci| **Name**| **Type**| **Mandatory**| Description                                   |
205e41f4b71Sopenharmony_ci| ---------- | -------- | -------- | --------------------------------------- |
206e41f4b71Sopenharmony_ci| position   | number   | Yes      | Position to move to, starting from 0.|
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci**Return value**
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci| Type   | Description                                         |
211e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
212e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci**Example**
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci```ts
217e41f4b71Sopenharmony_cilet goToRowNum = 2;
218e41f4b71Sopenharmony_ciif (resultSet != undefined) {
219e41f4b71Sopenharmony_ci  let isGoToRow = (resultSet as DataShareResultSet).goToRow(goToRowNum);
220e41f4b71Sopenharmony_ci  console.info('resultSet.goToRow: ' + isGoToRow);
221e41f4b71Sopenharmony_ci}
222e41f4b71Sopenharmony_ci```
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci### getBlob
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_cigetBlob(columnIndex: number): Uint8Array
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ciObtains the value in the form of a byte array based on the specified column and the current row.
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ciIf the specified column or key is empty or the value is not of the Blob type, you need to determine whether to throw an exception.
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci**Parameters**
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci| **Name** | **Type**| **Mandatory**| Description                   |
237e41f4b71Sopenharmony_ci| ----------- | -------- | -------- | ----------------------- |
238e41f4b71Sopenharmony_ci| columnIndex | number   | Yes      | Index of the target column, starting from 0.|
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci**Return value**
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci| Type      | Description                            |
243e41f4b71Sopenharmony_ci| ---------- | -------------------------------- |
244e41f4b71Sopenharmony_ci| Uint8Array | Value obtained.|
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci**Example**
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci```ts
249e41f4b71Sopenharmony_cilet columnIndex = 1;
250e41f4b71Sopenharmony_ciif (resultSet != undefined) {
251e41f4b71Sopenharmony_ci  let goToFirstRow = (resultSet as DataShareResultSet).goToFirstRow();
252e41f4b71Sopenharmony_ci  let getBlob = (resultSet as DataShareResultSet).getBlob(columnIndex);
253e41f4b71Sopenharmony_ci  console.info('resultSet.getBlob: ' + getBlob);
254e41f4b71Sopenharmony_ci}
255e41f4b71Sopenharmony_ci```
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci### getString
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_cigetString(columnIndex: number): string
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ciObtains the value in the form of a string based on the specified column and the current row.
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ciIf the specified column or key is empty or the value is not of the string type, you need to determine whether to throw an exception.
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_ci**Parameters**
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci| **Name** | **Type**| **Mandatory**| Description                   |
270e41f4b71Sopenharmony_ci| ----------- | -------- | -------- | ----------------------- |
271e41f4b71Sopenharmony_ci| columnIndex | number   | Yes      | Index of the target column, starting from 0.|
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci**Return value**
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci| Type  | Description                        |
276e41f4b71Sopenharmony_ci| ------ | ---------------------------- |
277e41f4b71Sopenharmony_ci| string | Value obtained.|
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci**Example**
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci```ts
282e41f4b71Sopenharmony_cilet columnIndex = 1;
283e41f4b71Sopenharmony_ciif (resultSet != undefined) {
284e41f4b71Sopenharmony_ci  let goToFirstRow = (resultSet as DataShareResultSet).goToFirstRow();
285e41f4b71Sopenharmony_ci  let getString = (resultSet as DataShareResultSet).getString(columnIndex);
286e41f4b71Sopenharmony_ci  console.info('resultSet.getString: ' + getString);
287e41f4b71Sopenharmony_ci}
288e41f4b71Sopenharmony_ci```
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci### getLong
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_cigetLong(columnIndex: number): number
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ciObtains the value in the form of a long integer based on the specified column and the current row.
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ciIf the specified column or key is empty or the value is not of the long type, you need to determine whether to throw an exception.
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci**Parameters**
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci| **Name** | **Type**| **Mandatory**| Description                   |
303e41f4b71Sopenharmony_ci| ----------- | -------- | -------- | ----------------------- |
304e41f4b71Sopenharmony_ci| columnIndex | number   | Yes      | Index of the target column, starting from 0.|
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci**Return value**
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ci| Type  | Description                      |
309e41f4b71Sopenharmony_ci| ------ | -------------------------- |
310e41f4b71Sopenharmony_ci| number | Value obtained.|
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci**Example**
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci```ts
315e41f4b71Sopenharmony_cilet columnIndex = 1;
316e41f4b71Sopenharmony_ciif (resultSet != undefined) {
317e41f4b71Sopenharmony_ci  let goToFirstRow = (resultSet as DataShareResultSet).goToFirstRow();
318e41f4b71Sopenharmony_ci  let getLong = (resultSet as DataShareResultSet).getLong(columnIndex);
319e41f4b71Sopenharmony_ci  console.info('resultSet.getLong: ' + getLong);
320e41f4b71Sopenharmony_ci}
321e41f4b71Sopenharmony_ci```
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci### getDouble
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_cigetDouble(columnIndex: number): number
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ciObtains the value in the form of a double-precision floating-point number based on the specified column and the current row.
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ciIf the specified column or key is empty or the value is not of the double type, you need to determine whether to throw an exception.
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci**Parameters**
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci| **Name** | **Type**| **Mandatory**| Description                   |
336e41f4b71Sopenharmony_ci| ----------- | -------- | -------- | ----------------------- |
337e41f4b71Sopenharmony_ci| columnIndex | number   | Yes      | Index of the target column, starting from 0.|
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci**Return value**
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci| Type  | Description                        |
342e41f4b71Sopenharmony_ci| ------ | ---------------------------- |
343e41f4b71Sopenharmony_ci| number | Value obtained.|
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci**Example**
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci```ts
348e41f4b71Sopenharmony_cilet columnIndex = 1;
349e41f4b71Sopenharmony_ciif (resultSet != undefined) {
350e41f4b71Sopenharmony_ci  let goToFirstRow = (resultSet as DataShareResultSet).goToFirstRow();
351e41f4b71Sopenharmony_ci  let getDouble = (resultSet as DataShareResultSet).getDouble(columnIndex);
352e41f4b71Sopenharmony_ci  console.info('resultSet.getDouble: ' + getDouble);
353e41f4b71Sopenharmony_ci}
354e41f4b71Sopenharmony_ci```
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci### close
357e41f4b71Sopenharmony_ci
358e41f4b71Sopenharmony_ciclose(): void
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_ciCloses this result set.
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ciCalling this API will invalidate the result set and release all its resources.
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci**Example**
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci```ts
369e41f4b71Sopenharmony_ciif (resultSet != undefined) {
370e41f4b71Sopenharmony_ci  (resultSet as DataShareResultSet).close();
371e41f4b71Sopenharmony_ci}
372e41f4b71Sopenharmony_ci```
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ci### getColumnIndex
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_cigetColumnIndex(columnName: string): number
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ciObtains the column index based on a column name.
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ciThe column name is passed in as an input parameter.
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
383e41f4b71Sopenharmony_ci
384e41f4b71Sopenharmony_ci**Parameters**
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ci| **Name**| **Type**| **Mandatory**| Description                      |
387e41f4b71Sopenharmony_ci| ---------- | -------- | -------- | -------------------------- |
388e41f4b71Sopenharmony_ci| columnName | string   | Yes      | Column name.|
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci**Return value**
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ci| Type  | Description              |
393e41f4b71Sopenharmony_ci| ------ | ------------------ |
394e41f4b71Sopenharmony_ci| number | Column index obtained.|
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci**Example**
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ci```ts
399e41f4b71Sopenharmony_cilet ColumnName = "name";
400e41f4b71Sopenharmony_ciif (resultSet != undefined) {
401e41f4b71Sopenharmony_ci  let getColumnIndex = (resultSet as DataShareResultSet).getColumnIndex(ColumnName);
402e41f4b71Sopenharmony_ci  console.info('resultSet.getColumnIndex: ' + getColumnIndex);
403e41f4b71Sopenharmony_ci}
404e41f4b71Sopenharmony_ci```
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci### getColumnName
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_cigetColumnName(columnIndex: number): string
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ciObtains the column name based on a column index.
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ciThe column index is passed in as an input parameter.
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci**Parameters**
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci| **Name** | **Type**| **Mandatory**| Description                      |
419e41f4b71Sopenharmony_ci| ----------- | -------- | -------- | -------------------------- |
420e41f4b71Sopenharmony_ci| columnIndex | number   | Yes      | Column index.|
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci**Return value**
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci| Type  | Description              |
425e41f4b71Sopenharmony_ci| ------ | ------------------ |
426e41f4b71Sopenharmony_ci| string | Column name obtained.|
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ci**Example**
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci```ts
431e41f4b71Sopenharmony_cilet columnIndex = 1;
432e41f4b71Sopenharmony_ciif (resultSet != undefined) {
433e41f4b71Sopenharmony_ci  let getColumnName = (resultSet as DataShareResultSet).getColumnName(columnIndex);
434e41f4b71Sopenharmony_ci  console.info('resultSet.getColumnName: ' + getColumnName);
435e41f4b71Sopenharmony_ci}
436e41f4b71Sopenharmony_ci```
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci### getDataType
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_cigetDataType(columnIndex: number): DataType
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ciObtains the data type based on the specified column index.
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ciIf the specified column or key is empty or the value is not of the DataType type, you need to determine whether to throw an exception.
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ci**Parameters**
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci| **Name** | **Type**| **Mandatory**| Description                      |
451e41f4b71Sopenharmony_ci| ----------- | -------- | -------- | -------------------------- |
452e41f4b71Sopenharmony_ci| columnIndex | number   | Yes      | Column index.|
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci**Return value**
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci| Type                 | Description              |
457e41f4b71Sopenharmony_ci| --------------------- | ------------------ |
458e41f4b71Sopenharmony_ci| [DataType](#datatype) | Data type obtained.|
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci**Example**
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci```ts
463e41f4b71Sopenharmony_cilet columnIndex = 1;
464e41f4b71Sopenharmony_ciif (resultSet != undefined) {
465e41f4b71Sopenharmony_ci  let getDataType = (resultSet as DataShareResultSet).getDataType(columnIndex);
466e41f4b71Sopenharmony_ci  console.info('resultSet.getDataType: ' + getDataType);
467e41f4b71Sopenharmony_ci}
468e41f4b71Sopenharmony_ci```
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ci## DataType
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ciEnumerates the data types.
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci| Name       | Value| Description                |
477e41f4b71Sopenharmony_ci| ----------- | ------ | -------------------- |
478e41f4b71Sopenharmony_ci| TYPE_NULL   | 0      | Null.    |
479e41f4b71Sopenharmony_ci| TYPE_LONG   | 1      | Long integer.  |
480e41f4b71Sopenharmony_ci| TYPE_DOUBLE | 2      | Double-precision floating-point number.|
481e41f4b71Sopenharmony_ci| TYPE_STRING | 3      | String.|
482e41f4b71Sopenharmony_ci| TYPE_BLOB   | 4      | Byte array.|
483