問題描述
我需要使用 node js 使用第三方 webservice 并將其寫入 oracle table .基本上我得到了獲取數據的代碼.基本上需要獲取該輸出并插入到 Oracle clob 列中.有人可以通過示例指導我.
i need to consume third party webservice using node js and write it on oracle table . basically i got the code for getting the data. Basically need to take that output and insert into a Oracle clob columns.Can someone guide me with examples.
推薦答案
一些資源:
https://github.com/oracle/node-oracledb/tree/master/examples 有 LOB 示例,例如 lobinsert1.js 和 lobinsert2.js
https://github.com/oracle/node-oracledb/tree/master/examples has LOB examples, for example lobinsert1.js and lobinsert2.js
node-oracledb 手冊中有大量關于在 node-oracledb 中使用 LOB 的文檔,請參閱 使用 CLOB、NCLOB 和 BLOB 數據.
There is plenty of documentation on using LOBs in node-oracledb in the node-oracledb manual, see Working with CLOB, NCLOB and BLOB Data.
例如:
// 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
文件.由于我不知道該網絡服務是什么,因此無法發表更多評論.
In your case you would read str
from your web service instead of a disk
file. Since I don't know what that web service is, I can't comment more.
node-oracledb 的安裝說明在這里.
Installation instructions for node-oracledb are here.
這篇關于使用 Web 服務并使用 Node.js 將 CLOB 插入 Oracle 數據庫表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!