resolved null value in db custom types
This commit is contained in:
parent
284c323235
commit
76a07a0451
8
package-lock.json
generated
8
package-lock.json
generated
@ -36,7 +36,7 @@
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/mssql": "^9.1.7",
|
||||
"@types/node": "^22.10.7",
|
||||
"@types/oracledb": "^6.5.3",
|
||||
"@types/oracledb": "^6.5.4",
|
||||
"@types/supertest": "^6.0.2",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
@ -3507,9 +3507,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/oracledb": {
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/oracledb/-/oracledb-6.5.3.tgz",
|
||||
"integrity": "sha512-qrcKBezSXi8MltjKtYOQTN+tk7YjeiLjLO4SgXuzGvUGmLMkDLWTRJ4OtM3YoW9dzi/tQeUdgatTmOOE3nSAVg==",
|
||||
"version": "6.5.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/oracledb/-/oracledb-6.5.4.tgz",
|
||||
"integrity": "sha512-aog21Z8stj//MGECcP/ZdwImubmLs5iqWji8xkyPPH5nRz3LTGiXpljQvWRFm76/m+Mgg4NlKegC2J/TTAhK7A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/mssql": "^9.1.7",
|
||||
"@types/node": "^22.10.7",
|
||||
"@types/oracledb": "^6.5.3",
|
||||
"@types/oracledb": "^6.5.4",
|
||||
"@types/supertest": "^6.0.2",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
|
||||
@ -436,13 +436,48 @@ export class HomePageService {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
console.log("here ------------ 1");
|
||||
|
||||
// const res = await connection.execute(`SELECT CARNETSYS.GLARRAY(1, 'Description for itemno 1', 2500, 20, 12, 'LBS', 'US') FROM dual`);
|
||||
|
||||
async function createGLArrayInstance(connection, itemNo, itemDescription, itemValue, noOfPieces, itemWeight, itemWeightUOM, goodsOriginCountry) {
|
||||
const result = await connection.execute(
|
||||
`SELECT CARNETSYS.GLARRAY(:itemNo, :itemDescription, :itemValue, :noOfPieces, :itemWeight, :itemWeightUOM, :goodsOriginCountry) FROM dual`,
|
||||
{
|
||||
itemNo,
|
||||
itemDescription,
|
||||
itemValue,
|
||||
noOfPieces,
|
||||
itemWeight,
|
||||
itemWeightUOM,
|
||||
goodsOriginCountry
|
||||
}
|
||||
);
|
||||
return result.rows[0][0]; // Access the first row and first column to get the GLARRAY instance
|
||||
}
|
||||
|
||||
async function createCarnetCountryArrayInstance(connection, visitTransitInd, countryCode, noOfTimesEntLeave) {
|
||||
const result = await connection.execute(
|
||||
`SELECT CARNETSYS.CARNETCOUNTRYARRAY(:visitTransitInd, :countryCode, :noOfTimesEntLeave) FROM dual`,
|
||||
{
|
||||
visitTransitInd,
|
||||
countryCode,
|
||||
noOfTimesEntLeave
|
||||
}
|
||||
);
|
||||
return result.rows[0][0]; // Access the first row and first column to get the CARNETCOUNTRYARRAY instance
|
||||
}
|
||||
|
||||
|
||||
// let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name IN ('GLARRAY', 'GLTABLE')`)
|
||||
|
||||
const GLARRAY = await connection.getDbObjectClass('CARNETSYS.GLARRAY');
|
||||
let GLARRAY = await connection.getDbObjectClass('CARNETSYS.GLARRAY');
|
||||
const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
|
||||
const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
|
||||
const CARNETCOUNTRYTABLE = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYTABLE');
|
||||
|
||||
console.log("here ------------ 2");
|
||||
|
||||
// Check if GLTABLE is a constructor
|
||||
if (typeof GLTABLE !== 'function') {
|
||||
throw new Error('GLTABLE is not a constructor');
|
||||
@ -452,19 +487,44 @@ export class HomePageService {
|
||||
throw new Error('CARNETCOUNTRYTABLE is not a constructor');
|
||||
}
|
||||
|
||||
const GLTABLE_ARRAY = finalBody.p_gltable ? finalBody.p_gltable.map((x: p_gltableDTO) => {
|
||||
return new GLARRAY(x.ItemNo, x.ItemDescription, x.ItemValue, x.Noofpieces, x.ItemWeight, x.ItemWeightUOM, x.GoodsOriginCountry)
|
||||
}) : [];
|
||||
console.log("here ------------ 3");
|
||||
// console.log(finalBody);
|
||||
|
||||
const CARNETCOUNTRYTABLE_ARRAY = finalBody.p_countrytable ? finalBody.p_countrytable.map((x: p_countrytableDTO) => {
|
||||
return new CARNETCOUNTRYARRAY(x.VisitTransitInd, x.CountryCode, x.NoOfTimesEntLeave)
|
||||
}) : [];
|
||||
let k = new GLARRAY(1, 'Description for itemno 1', 2500, 20,12,'LBS','US')
|
||||
|
||||
// return {k}
|
||||
|
||||
|
||||
|
||||
const GLTABLE_ARRAY = finalBody.p_gltable ? await Promise.all(finalBody.p_gltable.map(async (x:p_gltableDTO) => {
|
||||
return await createGLArrayInstance(connection, x.ItemNo, x.ItemDescription, x.ItemValue, x.Noofpieces, x.ItemWeight, x.ItemWeightUOM, x.GoodsOriginCountry);
|
||||
})) : [];
|
||||
|
||||
console.log("here ------------ 4");
|
||||
|
||||
const CARNETCOUNTRYTABLE_ARRAY = finalBody.p_countrytable ? await Promise.all(finalBody.p_countrytable.map(async (x) => {
|
||||
return await createCarnetCountryArrayInstance(connection, x.VisitTransitInd, x.CountryCode, x.NoOfTimesEntLeave);
|
||||
})) : [];
|
||||
|
||||
console.log("CARNETCOUNTRYTABLE_ARRAY : ", CARNETCOUNTRYTABLE_ARRAY[0], CARNETCOUNTRYTABLE_ARRAY[1]);
|
||||
|
||||
|
||||
console.log("here ------------ 5");
|
||||
|
||||
// Create an instance of GLTABLE
|
||||
const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY);
|
||||
const CARNETCOUNTRYTABLE_INSTANCE = new CARNETCOUNTRYTABLE(CARNETCOUNTRYTABLE_ARRAY);
|
||||
|
||||
// return { GLTABLE_INSTANCE,CARNETCOUNTRYTABLE_INSTANCE };
|
||||
console.log(finalBody);
|
||||
console.log(GLTABLE_INSTANCE);
|
||||
console.log(CARNETCOUNTRYTABLE_INSTANCE);
|
||||
|
||||
|
||||
|
||||
|
||||
console.log("here ------------ 6");
|
||||
|
||||
// return { GLTABLE_INSTANCE, CARNETCOUNTRYTABLE_INSTANCE };
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user