@@ -3703,11 +3703,11 @@ This function provides query streaming support. The parameters are
37033703the same as [`execute()`](#execute) except a callback is not used.
37043704Instead this function returns a stream used to fetch data.
37053705
3706- Each row is returned as a `data` event. Query metadata is available
3707- via a `metadata` event. The `end` event indicates the end of the
3708- query results.
3709-
3710- The connection must remain open until the stream is completely read .
3706+ Each row is returned as a `data` event. Query metadata is available via a
3707+ `metadata` event. The `end` event indicates the end of the query results. The
3708+ connection must remain open until the stream is completely read and the `close`
3709+ event received. Alternatively the Stream [`destroy()`][92] method can be used
3710+ to terminate a stream early .
37113711
37123712For tuning, adjust the value of
37133713[`oracledb.fetchArraySize`](#propdbfetcharraysize) or the
@@ -8841,22 +8841,23 @@ await rs.close();
88418841Streaming of query results allows data to be piped to other streams,
88428842for example when dealing with HTTP responses.
88438843
8844- Use [`connection.queryStream()`](#querystream) to create a stream from
8845- a top level query and listen for events. You can also call
8846- [`connection.execute()`](#execute) and use
8847- [`toQueryStream()`](#toquerystream) to return a stream from the
8848- returned [ ResultSet](#resultsetclass), an OUT bind REF CURSOR
8849- ResultSet, or [Implicit Results](#implicitresults) ResultSet .
8844+ Use [`connection.queryStream()`](#querystream) to create a stream from a top
8845+ level query and listen for events. You can also call
8846+ [`connection.execute()`](#execute) and use [`toQueryStream()`](#toquerystream)
8847+ to return a stream from the returned [ResultSet](#resultsetclass), from an OUT
8848+ bind REF CURSOR ResultSet, or from [Implicit Results](#implicitresults)
8849+ ResultSets .
88508850
8851- With streaming, each row is returned as a `data` event. Query
8852- metadata is available via a `metadata` event. The `end` event
8853- indicates the end of the query results.
8851+ With streaming, each row is returned as a `data` event. Query metadata is
8852+ available via a `metadata` event. The `end` event indicates the end of the
8853+ query results, however it is generally best to put end-of-fetch logic in the
8854+ `close` event.
88548855
88558856Query results should be fetched to completion to avoid resource leaks, or the
8856- Stream [`destroy()`][92] method can be used to terminate a stream early.
8857-
8858- The connection must remain open until the stream is completely read
8859- and any returned [Lob](#lobclass) objects have been processed.
8857+ Stream [`destroy()`][92] method can be used to terminate a stream early. When
8858+ fetching, the connection must remain open until the stream is completely read
8859+ and the `close` event received. Any returned [Lob](#lobclass) objects should
8860+ also be processed first .
88608861
88618862The query stream implementation is a wrapper over the [ResultSet
88628863Class](#resultsetclass). In particular, successive calls to
@@ -8879,7 +8880,11 @@ stream.on('data', function (data) {
88798880});
88808881
88818882stream.on('end', function () {
8882- // release connection...
8883+ // all data has been fetched...
8884+ });
8885+
8886+ stream.on('close', function () {
8887+ // can now close connection... (Note: do not close connections on 'end')
88838888});
88848889
88858890stream.on('metadata', function (metadata) {
0 commit comments