From e9eb086f9e779f6ef22b7e9ddce2e8db6c538adc Mon Sep 17 00:00:00 2001 From: Kallesh B S Date: Mon, 21 Jul 2025 20:33:19 +0530 Subject: [PATCH] added new GET_COUNTRIES_AND_MESSAGES API in param --- .../param-table/param-table.controller.ts | 5 +++ src/oracle/param-table/param-table.service.ts | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/oracle/param-table/param-table.controller.ts b/src/oracle/param-table/param-table.controller.ts index b94538f..67ddf0b 100644 --- a/src/oracle/param-table/param-table.controller.ts +++ b/src/oracle/param-table/param-table.controller.ts @@ -36,6 +36,11 @@ export class ParamTableController { return this.paramTableService.GETPARAMVALUES(body); } + @Get('GetCountriesAndMessages') + GET_COUNTRIES_AND_MESSAGES() { + return this.GET_COUNTRIES_AND_MESSAGES(); + } + @Post('/CreateTableRecord') createTableRecord(@Body() body: CreateTableRecordDTO) { return this.paramTableService.CREATETABLERECORD(body); diff --git a/src/oracle/param-table/param-table.service.ts b/src/oracle/param-table/param-table.service.ts index da1627d..a845f7c 100644 --- a/src/oracle/param-table/param-table.service.ts +++ b/src/oracle/param-table/param-table.service.ts @@ -63,6 +63,38 @@ export class ParamTableService { } } + async GET_COUNTRIES_AND_MESSAGES() { + let connection; + try { + connection = await this.oracleDBService.getConnection(); + + const result = await connection.execute( + `BEGIN + MANAGEPARAMTABLE_PKG.GetCountriesAndMessages(:P_CURSOR); + END;`, + { + P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, + { outFormat: oracledb.OUT_FORMAT_OBJECT } + ); + + await connection.commit(); + + const outBinds = result.outBinds; + if (!outBinds?.P_CURSOR) { + this.logger.error('One or more expected cursors are missing from stored procedure output.'); + throw new InternalServerException("Incomplete data received from the database."); + } + + return await fetchCursor(outBinds.P_CURSOR, ParamTableService.name); + + } catch (error) { + handleError(error, ParamTableService.name) + } finally { + await closeOracleDbConnection(connection, ParamTableService.name) + } + } + async CREATETABLERECORD(body: CreateTableRecordDTO) { let connection;