await did not wait for promise to come back
async function getDataFromDB(type,sql,connect_handler,data=[]){
return new Promise(function(resolve,reject){
if(type == "mysql"){
if(data.length == 0){
let t = connect_handler.query(sql,function(err,result,fields){
if(err){
//console.log(err);
reject(err);
}else{
//console.log(results);
// Promise.resolve(results);
resolve(result);
}
})
}else{
connect_handler.query(sql,data,function(err,result,fields){
if(err){
//console.log(err);
reject(err);
}else{
resolve(result);
}
})
}
}else if(type == "oracledb"){
if(data.length == 0){
connect_handler.execute(sql,function(err,result){
if(err){
//console.log(err);
reject(err);
}else{
resolve(result);
}
})
}else{
connect_handler.execute(sql,data,function(err,result){
if(err){
//console.log(err);
reject(err);
}else{
//console.log(result);
resolve(result);
}
})
}
}else{
console.error("mysqloracledb");
}
})
}
connection.then(async function([oracle_connect,mysql_connect]){
console.log("");
let studentNoSet = await getDataFromDB("mysql",`select distinct stu_no from stu_detail`,mysql_connect);
**console.log(studentNoSet); // promise**
/*studentNoSet.then(function(data){
console.log(data);
console.log("");
process.exit(1);
}).catch(function(err){
console.log(err);
});*/
});