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/jest": "^29.5.14",
|
||||||
"@types/mssql": "^9.1.7",
|
"@types/mssql": "^9.1.7",
|
||||||
"@types/node": "^22.10.7",
|
"@types/node": "^22.10.7",
|
||||||
"@types/oracledb": "^6.5.3",
|
"@types/oracledb": "^6.5.4",
|
||||||
"@types/supertest": "^6.0.2",
|
"@types/supertest": "^6.0.2",
|
||||||
"eslint": "^9.18.0",
|
"eslint": "^9.18.0",
|
||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint-config-prettier": "^10.0.1",
|
||||||
@ -3507,9 +3507,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/oracledb": {
|
"node_modules/@types/oracledb": {
|
||||||
"version": "6.5.3",
|
"version": "6.5.4",
|
||||||
"resolved": "https://registry.npmjs.org/@types/oracledb/-/oracledb-6.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/oracledb/-/oracledb-6.5.4.tgz",
|
||||||
"integrity": "sha512-qrcKBezSXi8MltjKtYOQTN+tk7YjeiLjLO4SgXuzGvUGmLMkDLWTRJ4OtM3YoW9dzi/tQeUdgatTmOOE3nSAVg==",
|
"integrity": "sha512-aog21Z8stj//MGECcP/ZdwImubmLs5iqWji8xkyPPH5nRz3LTGiXpljQvWRFm76/m+Mgg4NlKegC2J/TTAhK7A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@ -47,7 +47,7 @@
|
|||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/mssql": "^9.1.7",
|
"@types/mssql": "^9.1.7",
|
||||||
"@types/node": "^22.10.7",
|
"@types/node": "^22.10.7",
|
||||||
"@types/oracledb": "^6.5.3",
|
"@types/oracledb": "^6.5.4",
|
||||||
"@types/supertest": "^6.0.2",
|
"@types/supertest": "^6.0.2",
|
||||||
"eslint": "^9.18.0",
|
"eslint": "^9.18.0",
|
||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint-config-prettier": "^10.0.1",
|
||||||
|
|||||||
@ -436,13 +436,48 @@ export class HomePageService {
|
|||||||
throw new Error('No DB Connected')
|
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')`)
|
// 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 GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
|
||||||
const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
|
const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
|
||||||
const CARNETCOUNTRYTABLE = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYTABLE');
|
const CARNETCOUNTRYTABLE = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYTABLE');
|
||||||
|
|
||||||
|
console.log("here ------------ 2");
|
||||||
|
|
||||||
// Check if GLTABLE is a constructor
|
// Check if GLTABLE is a constructor
|
||||||
if (typeof GLTABLE !== 'function') {
|
if (typeof GLTABLE !== 'function') {
|
||||||
throw new Error('GLTABLE is not a constructor');
|
throw new Error('GLTABLE is not a constructor');
|
||||||
@ -452,18 +487,43 @@ export class HomePageService {
|
|||||||
throw new Error('CARNETCOUNTRYTABLE is not a constructor');
|
throw new Error('CARNETCOUNTRYTABLE is not a constructor');
|
||||||
}
|
}
|
||||||
|
|
||||||
const GLTABLE_ARRAY = finalBody.p_gltable ? finalBody.p_gltable.map((x: p_gltableDTO) => {
|
console.log("here ------------ 3");
|
||||||
return new GLARRAY(x.ItemNo, x.ItemDescription, x.ItemValue, x.Noofpieces, x.ItemWeight, x.ItemWeightUOM, x.GoodsOriginCountry)
|
// console.log(finalBody);
|
||||||
}) : [];
|
|
||||||
|
|
||||||
const CARNETCOUNTRYTABLE_ARRAY = finalBody.p_countrytable ? finalBody.p_countrytable.map((x: p_countrytableDTO) => {
|
let k = new GLARRAY(1, 'Description for itemno 1', 2500, 20,12,'LBS','US')
|
||||||
return new CARNETCOUNTRYARRAY(x.VisitTransitInd, x.CountryCode, x.NoOfTimesEntLeave)
|
|
||||||
}) : [];
|
// 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
|
// Create an instance of GLTABLE
|
||||||
const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY);
|
const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY);
|
||||||
const CARNETCOUNTRYTABLE_INSTANCE = new CARNETCOUNTRYTABLE(CARNETCOUNTRYTABLE_ARRAY);
|
const CARNETCOUNTRYTABLE_INSTANCE = new CARNETCOUNTRYTABLE(CARNETCOUNTRYTABLE_ARRAY);
|
||||||
|
|
||||||
|
console.log(finalBody);
|
||||||
|
console.log(GLTABLE_INSTANCE);
|
||||||
|
console.log(CARNETCOUNTRYTABLE_INSTANCE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
console.log("here ------------ 6");
|
||||||
|
|
||||||
// return { GLTABLE_INSTANCE, CARNETCOUNTRYTABLE_INSTANCE };
|
// return { GLTABLE_INSTANCE, CARNETCOUNTRYTABLE_INSTANCE };
|
||||||
|
|
||||||
const result = await connection.execute(
|
const result = await connection.execute(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user