【问题标题】:disable knex oracledb autocommit禁用 knex oracledb 自动提交
【发布时间】:2021-04-19 08:36:32
【问题描述】:

我已经将 knex 与 oracledb 客户端一起用于下一个配置

const database = knex({
  client: "oracledb",
  connection: {
    user: DB_USER,
    password: DB_PASS,
    host: DB_HOST,
    port: DB_PORT,
    database: DB_NAME,
  },
  debug: DEBUG_MODE,
  fetchAsString: ["number", "clob"],
});

当执行任何查询时,它会自动提交,我想禁用它!

database("EMPLOYEES")
 .where({ EMPLOYEE_ID: 100 })
 .update({ EMAIL: "hi@example.com" })

【问题讨论】:

    标签: node.js oracle knex.js


    【解决方案1】:

    点击here to see the original reply!

    
    To prevent autocommit you need to start transaction and run queries that should not be autocommitted there. If you disable autocommit you will not have any idea in what state each db session created by pool is.
    
    Though if you don’t care what result you may get or use just a single connection in that special case disabling autocommit could work. In that case it probably can be set with knex.raw().
    

    【讨论】:

    • 是的。禁用它不适用于 knex。您需要改用事务。
    猜你喜欢
    • 2016-01-13
    • 2016-05-06
    • 2015-02-16
    • 1970-01-01
    • 2021-09-05
    • 2017-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多