From 9f2d7f058fb82adcdf1491a6d4dcd28f32e3e45b Mon Sep 17 00:00:00 2001 From: Kallesh B S Date: Mon, 28 Jul 2025 21:01:57 +0530 Subject: [PATCH] transmit application and INACTIVATEPARAMRECORD typo fix and added getAllParamValues --- .../carnet-application.service.ts | 2 +- .../param-table/param-table.controller.ts | 17 +++++++ src/oracle/param-table/param-table.service.ts | 48 ++++++++++++++++++- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/oracle/carnet-application/carnet-application.service.ts b/src/oracle/carnet-application/carnet-application.service.ts index 4a95ccb..0d46de1 100644 --- a/src/oracle/carnet-application/carnet-application.service.ts +++ b/src/oracle/carnet-application/carnet-application.service.ts @@ -147,7 +147,7 @@ export class CarnetApplicationService { const result = await connection.execute( `BEGIN CARNETAPPLICATION_PKG.TransmitApplicationtoProcess( - :P_SPID, :P_USERID, :P_HEADERID :P_CURSOR + :P_SPID, :P_USERID, :P_HEADERID, :P_CURSOR ); END;`, { diff --git a/src/oracle/param-table/param-table.controller.ts b/src/oracle/param-table/param-table.controller.ts index da96a6a..24b52ed 100644 --- a/src/oracle/param-table/param-table.controller.ts +++ b/src/oracle/param-table/param-table.controller.ts @@ -36,6 +36,23 @@ export class ParamTableController { return this.paramTableService.GETPARAMVALUES(body); } + @Get('/GetAllParamValues') + @ApiQuery({ + name: 'P_SPID', + required: false, + type: Number, + description: 'The ID of the parameter', + }) + @ApiQuery({ + name: 'P_PARAMTYPE', + required: false, + type: String, + description: 'The type of the parameter', + }) + getAllParamValues(@Query() body: getParamValuesDTO) { + return this.paramTableService.GETALLPARAMVALUES(body); + } + @Get('GetCountriesAndMessages') @Roles('ca', 'sa', 'ua') GET_COUNTRIES_AND_MESSAGES() { diff --git a/src/oracle/param-table/param-table.service.ts b/src/oracle/param-table/param-table.service.ts index a845f7c..5414f5e 100644 --- a/src/oracle/param-table/param-table.service.ts +++ b/src/oracle/param-table/param-table.service.ts @@ -63,6 +63,52 @@ export class ParamTableService { } } + async GETALLPARAMVALUES(body: getParamValuesDTO) { + const finalBody = { + P_SPID: body.P_SPID === 0 ? body.P_SPID : body.P_SPID ? body.P_SPID : null, + P_PARAMTYPE: body.P_PARAMTYPE ? body.P_PARAMTYPE : null, + }; + + let connection; + try { + connection = await this.oracleDBService.getConnection(); + + const result = await connection.execute( + `BEGIN + MANAGEPARAMTABLE_PKG.GetAllParamValues(:P_SPID,:P_PARAMTYPE,:P_CURSOR); + END;`, + { + P_SPID: { val: finalBody.P_SPID, type: oracledb.DB_TYPE_NUMBER }, + P_PARAMTYPE: { val: finalBody.P_PARAMTYPE, type: oracledb.DB_TYPE_NVARCHAR }, + 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."); + } + + // const fres: any = await fetchCursor(outBinds.P_CURSOR, ParamTableService.name); + + // if (fres.length > 0 && fres[0].ERRORMESG) { + // this.logger.warn(fres[0].ERRORMESG); + // throw new BadRequestException(fres[0].ERRORMESG) + // } + + return await fetchCursor(outBinds.P_CURSOR, ParamTableService.name); + + } catch (error) { + handleError(error, ParamTableService.name) + } finally { + await closeOracleDbConnection(connection, ParamTableService.name) + } + } + async GET_COUNTRIES_AND_MESSAGES() { let connection; try { @@ -254,7 +300,7 @@ export class ParamTableService { const result = await connection.execute( `BEGIN - MANAGEPARAMTABLE_PKG.REACTIVATEPARAMRECORD(:P_PARAMID,:P_USERID); + MANAGEPARAMTABLE_PKG.INACTIVATEPARAMRECORD(:P_PARAMID,:P_USERID); END;`, { P_PARAMID: { val: body.P_PARAMID, type: oracledb.DB_TYPE_NUMBER },