node. JS connection DB2 Implementation fetchrows line to get SQL source code

Source: Internet
Author: User
Tags db2

See the QueryResult part of the program:

/** This example demonstrates-to-fetch a single row from a large table* One by one and get processed by application. It avoids allocation of* Large memory by the ibm_db and data processing becomes easier. ** This example have used Sync methods, but async methods also exist. */var Ibmdb = require (".. /")//require ("ibm_db"), conn =NewIbmdb. Database (), CN ="Database=sample;hostname=hotel.torolab.ibm.com;port=21169;uid=newton;pwd=xxxx";//OpenA connection to  the DatabaseConn.opensync (CN);//Create Table  and Insert some rows  toIt.conn.querySync ("CREATE TABLE Mytab (c1 int, c2 varchar)"); Conn.querysync ("INSERT into mytab values (1, ' Bimal '), (2, ' Kamal '), (3, ' Mohan '), (4, ' Ram ')");//Select Data  from TableConn.queryresult ("SELECT * from Mytab",function(Err, result) {if(ERR) {Console.log (ERR);return; }//Fetch Single Row  atOnce andProcess it. Note that QueryResult'll bring only64kData  fromServer andResult.fetchsync//wouldreturn  each Row  fromThis 64k client buffer. Once All Data  is Read  fromBuffer, ibm_db driver'll bring another 64kChunk  of Data  fromServer. VarData; while(Data= Result.fetchsync ()) {Console.log (Data); }  //Drop  the Table  and CloseConnection. Conn.querysync ("drop table Mytab"); Conn.closesync ();});

Reference Link: https://github.com/ibmdb/node-ibm_db/blob/master/examples/singleRowFetch.js

node. JS connection DB2 Implementation fetchrows line to get SQL source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.