| 169 | return res; |
| 170 | } catch (error) { |
| 171 | await this.client!.query("ROLLBACK TO SAVEPOINT abap_stmt; RELEASE SAVEPOINT abap_stmt;"); |
| 172 | throw error; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | public async delete(options: DB.DeleteDatabaseOptions): Promise<{ subrc: number; dbcnt: number; }> { |
| 177 | this.checkFatal(); |
| 178 | if (this.lazy === true && this.pool === undefined) { |
| 179 | await this.connect(); |
| 180 | } |
| 181 | |
| 182 | let sql = `DELETE FROM ${options.table}`; |
| 183 | if (options.where !== "") { |
| 184 | sql += ` WHERE ${options.where}`; |
| 185 | } |
| 186 | |
| 187 | let subrc = 0; |
| 188 | let dbcnt = 0; |
| 189 | try { |
| 190 | if (this.trace === true) { |
| 191 | console.log(sql); |
| 192 | } |
| 193 | |
| 194 | const res = await this.modifying(sql); |
| 195 | dbcnt = res?.rowCount || 0; |
| 196 | if (dbcnt === 0) { |
| 197 | subrc = 4; |
| 198 | } |
| 199 | } catch (error) { |
| 200 | subrc = 4; |
| 201 | } |
| 202 | |
| 203 | return {subrc, dbcnt}; |
| 204 | } |
| 205 | |
| 206 | public async update(options: DB.UpdateDatabaseOptions): Promise<{ subrc: number; dbcnt: number; }> { |
| 207 | this.checkFatal(); |
| 208 | if (this.lazy === true && this.pool === undefined) { |
| 209 | await this.connect(); |
| 210 | } |
| 211 | |
| 212 | const sql = `UPDATE ${options.table} SET ${options.set.join(", ")} WHERE ${options.where}`; |
| 213 | |
| 214 | let subrc = 0; |