[关闭]
@WrRan 2016-11-18T07:32:10.000000Z 字数 2138 阅读 1433

node-oracledb

7. ResultSet Class

Result sets allow query results to fetched from the database one at a time, or in groups of rows. They can also be converted to Readable Streams. Result sets enable applications to process very large data sets.

Result sets should also be used where the number of query rows cannot be predicted and may be larger than a sensible maxRows size.

A ResultSet object is obtained by setting resultSet: true in the options parameter of the Connection execute() method when executing a query. A ResultSet is also returned to node-oracledb when binding as type CURSOR to a PL/SQL REF CURSOR bind parameter.

The value of prefetchRows can be adjusted to tune the performance of result sets.

See ResultSet Handling for more information on result sets.

7.1 ResultSet Properties

The properties of a ResultSet object are listed below.

7.1.1 metaData

  1. Array metaData

Contains an array of objects with metadata about the query or REF CURSOR columns.

Each column's name is always given. If the Oracledb extendedMetaData or execute() option extendedMetaData are true then additional information is included.

See result.metaData for the available attributes.

7.2 ResultSet Methods

7.2.1 close()

Prototype

Callback:

  1. close(function(Error error){});

Promise:

  1. promise = close();
Description

Closes a ResultSet. Applications should always call this at the end of fetch or when no more rows are needed.

7.2.2 getRow()

Prototype

Callback:

  1. getRow(function(Error error, Object row){});

Promise:

  1. promise = getRow();
Description

This call fetches one row of the result set as an object or an array of column values, depending on the value of outFormat.

At the end of fetching, the ResultSet should be freed by calling close().

7.2.3 getRows()

Prototype

Callback:

  1. getRows(Number numRows, function(Error error, Array rows){});

Promise:

  1. promise = getRows(Number numRows);
Description

This call fetches numRows rows of the result set as an object or an array of column values, depending on the value of outFormat.

At the end of fetching, the ResultSet should be freed by calling close().

7.2.4 toQueryStream()

Prototype
  1. toQueryStream();
Return Value

This method will return a Readable Stream.

Description

This synchronous method converts a ResultSet into a stream.

It can be used to make ResultSets from top-level queries or from REF CURSOR bind variables streamable. To make top-level queries streamable, the alternative connection.queryStream() method may be easier to use.

See Streaming Query Results for more information.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注