1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 import { AsyncCallback } from '../../basic' 17 18 /** 19 * Provides methods for accessing a database result set generated by querying the database. 20 * 21 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 22 * @since 7 23 * @deprecated since 9 24 * @useinstead ohos.data.relationalStore.ResultSet 25 */ 26 export interface ResultSet { 27 28 /** 29 * Obtains the names of all columns in a result set. 30 * The column names are returned as a string array, in which the strings are in the same order 31 * as the columns in the result set. 32 * 33 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 34 * @since 7 35 * @deprecated since 9 36 * @useinstead ohos.data.relationalStore.ResultSet.columnNames 37 */ 38 columnNames: Array<string>; 39 40 /** 41 * Obtains the number of columns in the result set. 42 * The returned number is equal to the length of the string array returned by the 43 * columnCount method. 44 * 45 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 46 * @since 7 47 * @deprecated since 9 48 * @useinstead ohos.data.relationalStore.ResultSet.columnCount 49 */ 50 columnCount: number; 51 52 /** 53 * Obtains the number of rows in the result set. 54 * 55 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 56 * @since 7 57 * @deprecated since 9 58 * @useinstead ohos.data.relationalStore.ResultSet.rowCount 59 */ 60 rowCount: number; 61 62 /** 63 * Obtains the current index of the result set. 64 * The result set index starts from 0. 65 * 66 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 67 * @since 7 68 * @deprecated since 9 69 * @useinstead ohos.data.relationalStore.ResultSet.rowIndex 70 */ 71 rowIndex: number; 72 73 /** 74 * Checks whether the result set is positioned at the first row. 75 * 76 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 77 * @since 7 78 * @deprecated since 9 79 * @useinstead ohos.data.relationalStore.ResultSet.isAtFirstRow 80 */ 81 isAtFirstRow: boolean; 82 83 /** 84 * Checks whether the result set is positioned at the last row. 85 * 86 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 87 * @since 7 88 * @deprecated since 9 89 * @useinstead ohos.data.relationalStore.ResultSet.isAtLastRow 90 */ 91 isAtLastRow: boolean; 92 93 /** 94 * Checks whether the result set is positioned after the last row. 95 * 96 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 97 * @since 7 98 * @deprecated since 9 99 * @useinstead ohos.data.relationalStore.ResultSet.isEnded 100 */ 101 isEnded: boolean; 102 103 /** 104 * returns whether the cursor is pointing to the position before the first 105 * row. 106 * 107 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 108 * @since 7 109 * @deprecated since 9 110 * @useinstead ohos.data.relationalStore.ResultSet.isStarted 111 */ 112 isStarted: boolean; 113 114 /** 115 * Checks whether the current result set is closed. 116 * 117 * If the result set is closed by calling the close method, true will be returned. 118 * 119 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 120 * @since 7 121 * @deprecated since 9 122 * @useinstead ohos.data.relationalStore.ResultSet.isClosed 123 */ 124 isClosed: boolean; 125 126 /** 127 * Obtains the column index based on the specified column name. 128 * The column name is passed as an input parameter. 129 * 130 * @param {string} columnName - Indicates the name of the specified column in the result set. 131 * @returns {number} return the index of the specified column. 132 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 133 * @since 7 134 * @deprecated since 9 135 * @useinstead ohos.data.relationalStore.ResultSet.getColumnIndex 136 */ 137 getColumnIndex(columnName: string): number; 138 139 /** 140 * Obtains the column name based on the specified column index. 141 * The column index is passed as an input parameter. 142 * 143 * @param {number} columnIndex - Indicates the index of the specified column in the result set. 144 * @returns {string} returns the name of the specified column. 145 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 146 * @since 7 147 * @deprecated since 9 148 * @useinstead ohos.data.relationalStore.ResultSet.getColumnName 149 */ 150 getColumnName(columnIndex: number): string; 151 152 /** 153 * Go to the specified row of the result set forwards or backwards by an offset relative to its current position. 154 * A positive offset indicates moving backwards, and a negative offset indicates moving forwards. 155 * 156 * @param {number} offset - Indicates the offset relative to the current position. 157 * @returns {string} returns true if the result set is moved successfully and does not go beyond the range; 158 * returns false otherwise. 159 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 160 * @since 7 161 * @deprecated since 9 162 * @useinstead ohos.data.relationalStore.ResultSet.goTo 163 */ 164 goTo(offset: number): boolean; 165 166 /** 167 * Go to the specified row of the result set. 168 * 169 * @param {number} rowIndex - Indicates the index of the specified row, which starts from 0. 170 * @returns {boolean} returns true if the result set is moved successfully; returns false otherwise. 171 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 172 * @since 7 173 * @deprecated since 9 174 * @useinstead ohos.data.relationalStore.ResultSet.goToRow 175 */ 176 goToRow(position: number): boolean; 177 178 /** 179 * Go to the first row of the result set. 180 * 181 * @returns {boolean} returns true if the result set is moved successfully; 182 * returns false otherwise, for example, if the result set is empty. 183 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 184 * @since 7 185 * @deprecated since 9 186 * @useinstead ohos.data.relationalStore.ResultSet.goToFirstRow 187 */ 188 goToFirstRow(): boolean; 189 190 /** 191 * Go to the last row of the result set. 192 * 193 * @returns {boolean} returns true if the result set is moved successfully; 194 * returns false otherwise, for example, if the result set is empty. 195 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 196 * @since 7 197 * @deprecated since 9 198 * @useinstead ohos.data.relationalStore.ResultSet.goToLastRow 199 */ 200 goToLastRow(): boolean; 201 202 /** 203 * Go to the next row of the result set. 204 * 205 * @returns {boolean} returns true if the result set is moved successfully; 206 * returns false otherwise, for example, if the result set is already in the last row. 207 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 208 * @since 7 209 * @deprecated since 9 210 * @useinstead ohos.data.relationalStore.ResultSet.goToNextRow 211 */ 212 goToNextRow(): boolean; 213 214 /** 215 * Go to the previous row of the result set. 216 * 217 * @returns {boolean} returns true if the result set is moved successfully; 218 * returns false otherwise, for example, if the result set is already in the first row. 219 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 220 * @since 7 221 * @deprecated since 9 222 * @useinstead ohos.data.relationalStore.ResultSet.goToPreviousRow 223 */ 224 goToPreviousRow(): boolean; 225 226 /** 227 * Obtains the value of the specified column in the current row as a byte array. 228 * The implementation class determines whether to throw an exception if the value of the specified column 229 * in the current row is null or the specified column is not of the Blob type. 230 * 231 * @param {number} columnIndex - Indicates the specified column index, which starts from 0. 232 * @returns {Uint8Array} returns the value of the specified column as a byte array. 233 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 234 * @since 7 235 * @deprecated since 9 236 * @useinstead ohos.data.relationalStore.ResultSet.getBlob 237 */ 238 getBlob(columnIndex: number): Uint8Array; 239 240 /** 241 * Obtains the value of the specified column in the current row as string. 242 * The implementation class determines whether to throw an exception if the value of the specified column 243 * in the current row is null or the specified column is not of the string type. 244 * 245 * @param {number} columnIndex - Indicates the specified column index, which starts from 0. 246 * @returns {string} returns the value of the specified column as a string. 247 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 248 * @since 7 249 * @deprecated since 9 250 * @useinstead ohos.data.relationalStore.ResultSet.getString 251 */ 252 getString(columnIndex: number): string; 253 254 /** 255 * Obtains the value of the specified column in the current row as long. 256 * The implementation class determines whether to throw an exception if the value of the specified column 257 * in the current row is null, the specified column is not of the integer type. 258 * 259 * @param {number} columnIndex - Indicates the specified column index, which starts from 0. 260 * @returns {number} returns the value of the specified column as a long. 261 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 262 * @since 7 263 * @deprecated since 9 264 * @useinstead ohos.data.relationalStore.ResultSet.getLong 265 */ 266 getLong(columnIndex: number): number; 267 268 /** 269 * Obtains the value of the specified column in the current row as double. 270 * The implementation class determines whether to throw an exception if the value of the specified column 271 * in the current row is null, the specified column is not of the double type. 272 * 273 * @param {number} columnIndex - Indicates the specified column index, which starts from 0. 274 * @returns {number} returns the value of the specified column as a double. 275 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 276 * @since 7 277 * @deprecated since 9 278 * @useinstead ohos.data.relationalStore.ResultSet.getDouble 279 */ 280 getDouble(columnIndex: number): number; 281 282 /** 283 * Checks whether the value of the specified column in the current row is null. 284 * 285 * @param {number} columnIndex - Indicates the specified column index, which starts from 0. 286 * @returns {boolean} returns true if the value of the specified column in the current row is null; 287 * returns false otherwise. 288 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 289 * @since 7 290 * @deprecated since 9 291 * @useinstead ohos.data.relationalStore.ResultSet.isColumnNull 292 */ 293 isColumnNull(columnIndex: number): boolean; 294 295 /** 296 * Closes the result set. 297 * Calling this method on the result set will release all of its resources and makes it ineffective. 298 * 299 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 300 * @since 7 301 * @deprecated since 9 302 * @useinstead ohos.data.relationalStore.ResultSet.close 303 */ 304 close(): void; 305 } 306 307