使用 Web 服务并使用 Node.js 将 CLOB 插入 Oracle 数据库表

问题描述

我需要使用 node js 使用第三方 webservice 并将其写入 oracle table 。基本上我得到了获取数据的代码。基本上需要获取输出并插入到 Oracle clob 列中。有人可以通过示例指导我。

解决方法

一些资源:

例如:

    // Insert a CLOB
    const str = fs.readFileSync(clobInFileName,'utf8');
    result = await connection.execute(
      `INSERT INTO no_lobs (id,c) VALUES (:id,:c)`,{ id: 1,c: str }
    );
    if (result.rowsAffected != 1)
      throw new Error('CLOB was not inserted');
    else
      console.log('CLOB inserted from ' + clobInFileName);

在您的情况下,您将从您的网络服务而不是磁盘读取 str 文件。由于我不知道该网络服务是什么,因此无法发表更多评论。

node-oracledb 的安装说明为 here