简体   繁体   中英

Update query hangs in node-oracledb module

I am working with node-oracledb ( 3.1.2 ) module. Everything is working fine except update query. I am able to fire select, insert queries but when I try to fire upate query, then it seems query is getting hanged (no error, no result). I am writing the below code:

For creating connection:

module.exports.createErpConnection = async () => {
   try {
       connection = await oracleDB.getConnection({
           user: constants.databaseCredentials.user,
           password: constants.databaseCredentials.password,
           connectString: `${constants.databaseCredentials.connectString}/${constants.databaseCredentials.databaseName}`
       });

       if (connection) {
           response.status = 1;
           response.connection = connection
       } else {
           response.status = 0;
           response.message = constants.databaseStatus.ERP_DATABASE_CONNECTION_NOT_ESTABLISHED
       }
   } catch (exception) {
       response.status = 0;
       response.message = exception;
   } finally {
       return response;
   }
};

Firing update query:

async function updateProductStatInErp(connection) {
  let sql = `UPDATE product_master SET UPDATED_STAT='N'`;
  let options = {outFormat: oracledb.OBJECT, autoCommit: true};
  const res = await connection.connection.execute(sql, {}, options)
  // I am not getting either response nor error
}

Do I need to do anything addition for firing update query??

I have resolved this issue just by writing execute statement in try and catch block. Here is the code:

 try {
      const res = await connection.connection.execute(sql, {}, options)
      console.log('======= 185 =======', res)
  } catch (exception) {
      console.log('====== 186 =====', exception)
    }
Result =>> ====== 185 ======= { rowsAffected: 490 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM