@WrRan
2016-11-18T07:32:10.000000Z
字数 2138
阅读 1433
node-oracledb
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.
The properties of a ResultSet object are listed below.
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.
Callback:
close(function(Error error){});
Promise:
promise = close();
Closes a ResultSet
. Applications should always call this at the end of fetch or when no more rows are needed.
Callback:
getRow(function(Error error, Object row){});
Promise:
promise = getRow();
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()
.
Callback:
getRows(Number numRows, function(Error error, Array rows){});
Promise:
promise = getRows(Number numRows);
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()
.
toQueryStream();
This method will return a Readable Stream.
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.