問(wèn)題描述
我需要使用 node js 使用第三方 webservice 并將其寫入 oracle table .基本上我得到了獲取數(shù)據(jù)的代碼.基本上需要獲取該輸出并插入到 Oracle clob 列中.有人可以通過(guò)示例指導(dǎo)我.
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 手冊(cè)中有大量關(guān)于在 node-oracledb 中使用 LOB 的文檔,請(qǐng)參閱 使用 CLOB、NCLOB 和 BLOB 數(shù)據(jù).
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);
在您的情況下,您將從您的網(wǎng)絡(luò)服務(wù)而不是磁盤讀取 str
文件.由于我不知道該網(wǎng)絡(luò)服務(wù)是什么,因此無(wú)法發(fā)表更多評(píng)論.
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 的安裝說(shuō)明在這里.
Installation instructions for node-oracledb are here.
這篇關(guān)于使用 Web 服務(wù)并使用 Node.js 將 CLOB 插入 Oracle 數(shù)據(jù)庫(kù)表的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!