@@ -259,7 +259,8 @@ For installation information, see the [Node-oracledb Installation Instructions][
259
259
- 7.1.4 [`type`](#proplobtype)
260
260
- 7.2 [Lob Methods](#lobmethods)
261
261
- 7.2.1 [`close()`](#lobclose)
262
- - 7.2.2 [`getData()`](#lobgetdata)
262
+ - 7.2.2 [`destroy()`](#lobdestroy)
263
+ - 7.2.3 [`getData()`](#lobgetdata)
263
264
8. [Pool Class](#poolclass)
264
265
- 8.1 [Pool Properties](#poolproperties)
265
266
- 8.1.1 [`connectionsInUse`](#proppoolconnectionsinuse)
@@ -486,6 +487,7 @@ For installation information, see the [Node-oracledb Installation Instructions][
486
487
- 33.4 [Migrating from node-oracledb 3.0 to node-oracledb 3.1](#migratev30v31)
487
488
- 33.5 [Migrating from node-oracledb 3.1 to node-oracledb 4.0](#migratev31v40)
488
489
- 33.6 [Migrating from node-oracledb 4.0 to node-oracledb 4.1](#migratev40v41)
490
+ - 33.7 [Migrating from node-oracledb 4.1 to node-oracledb 4.2](#migratev41v42)
489
491
34. [Useful Resources for Node-oracledb](#otherresources)
490
492
491
493
## <a name="apimanual"></a> NODE-ORACLEDB API MANUAL
@@ -2913,7 +2915,7 @@ is initially empty. Data can be streamed to the LOB, which can then
2913
2915
be passed into PL/SQL blocks, or inserted into the database.
2914
2916
2915
2917
When no longer required, Lobs created with `createLob()` should be
2916
- closed with [`lob.close ()`](#lobclose ) because Oracle Database
2918
+ closed with [`lob.destroy ()`](#lobdestroy ) because Oracle Database
2917
2919
resources are held open if temporary LOBs are not closed.
2918
2920
2919
2921
Open temporary LOB usage can be monitored using the view
@@ -4662,7 +4664,7 @@ Number pieceSize
4662
4664
```
4663
4665
4664
4666
The number of bytes (for BLOBs) or characters (for CLOBs) to read for
4665
- each Stream ' data' event of a queried LOB.
4667
+ each Stream ` data` event of a queried LOB.
4666
4668
4667
4669
The default value is [`chunkSize`](#proplobchunksize).
4668
4670
@@ -4691,6 +4693,9 @@ a LOB is returned by a query.
4691
4693
4692
4694
#### <a name="lobclose"></a> 7.2.1 `lob.close()`
4693
4695
4696
+ **Note: this method is deprecated and [`lob.destroy()`](#lobdestroy) should be
4697
+ used instead.**
4698
+
4694
4699
##### Prototype
4695
4700
4696
4701
Callback:
@@ -4706,19 +4711,18 @@ promise = close();
4706
4711
4707
4712
Explicitly closes a Lob.
4708
4713
4709
- Lobs created with [`createLob()`](#connectioncreatelob) should be
4710
- explicitly closed with [`lob.close()`](#lobclose) when no longer
4711
- needed. This frees resources in node-oracledb and in Oracle Database.
4714
+ Lobs created with [`createLob()`](#connectioncreatelob) should be explicitly
4715
+ closed when no longer needed. This frees resources in node-oracledb and in
4716
+ Oracle Database.
4712
4717
4713
- Persistent or temporary Lobs returned from the database may also be
4714
- closed with `lob.close()` as long as streaming is not currently
4715
- happening. Note these Lobs are automatically closed when streamed to
4716
- completion or used as the source for an IN OUT bind. If you try to
4717
- close a Lob being used for streaming you will get the error *NJS-023:
4718
+ Persistent or temporary Lobs returned from the database may also be closed as
4719
+ long as streaming is not currently happening. Note these Lobs are automatically
4720
+ closed when streamed to completion or used as the source for an IN OUT bind. If
4721
+ you try to close a Lob being used for streaming you will get the error *NJS-023:
4718
4722
concurrent operations on a Lob are not allowed*.
4719
4723
4720
- The `lob.close()` method emits the [Node.js Stream][16] ' close' event
4721
- unless the Lob has already been explicitly or automatically closed.
4724
+ The `lob.close()` method emits the [Node.js Stream][16] ` close` event unless the
4725
+ Lob has already been explicitly or automatically closed.
4722
4726
4723
4727
The connection must be open when calling `lob.close()` on a temporary
4724
4728
LOB, such as those created by `createLob()`.
@@ -4740,7 +4744,43 @@ See [Closing Lobs](#closinglobs) for more discussion.
4740
4744
*Error error* | If `close()` succeeds, `error` is NULL. If an error occurs, then `error` contains the [error message](#errorobj).
4741
4745
4742
4746
4743
- #### <a name="lobgetdata"></a> 7.2.2 `lob.getData()`
4747
+ #### <a name="lobdestroy"></a> 7.2.2 `lob.destroy()`
4748
+
4749
+ ##### Prototype
4750
+
4751
+ ```
4752
+ destroy([Error error]);
4753
+ ```
4754
+
4755
+ ##### Description
4756
+
4757
+ This synchronous method explicitly destroys a Lob.
4758
+
4759
+ Lobs created with [`createLob()`](#connectioncreatelob) should be
4760
+ explicitly closed with `lob.destroy()` when no longer
4761
+ needed. This frees resources in node-oracledb and in Oracle Database.
4762
+
4763
+ Persistent or temporary Lobs returned from the database may also be
4764
+ closed with `lob.destroy()`. Note these Lobs are automatically closed when streamed to
4765
+ completion or used as the source for an IN OUT bind.
4766
+
4767
+ The `lob.destroy()` method emits the [Node.js Stream][16] `close` event.
4768
+
4769
+ Once a Lob is destroyed, it cannot be used.
4770
+
4771
+ See [Closing Lobs](#closinglobs) for more discussion.
4772
+
4773
+ ##### Parameters
4774
+
4775
+ - ```
4776
+ Error error
4777
+ ```
4778
+
4779
+ Parameter | Description
4780
+ ----------------------------|-------------
4781
+ *Error error* | This optional parameter is used for the error emitted in an `error` event.
4782
+
4783
+ #### <a name="lobgetdata"></a> 7.2.3 `lob.getData()`
4744
4784
4745
4785
##### Prototype
4746
4786
@@ -10509,12 +10549,12 @@ get data.
10509
10549
The `read(size)` unit is in characters for CLOBs and in bytes for
10510
10550
BLOBs.
10511
10551
10512
- When reading a LOB from the database, resources are automatically
10513
- released at completion of the readable stream or if there is a LOB
10514
- error. The `lob.close ()` method can also be used to close persistent
10515
- LOBs that have not been streamed to completion.
10552
+ When reading a LOB from the database, resources are automatically released at
10553
+ completion of the readable stream or if there is a LOB error. The
10554
+ [ `lob.destroy ()`](#lobdestroy) method can also be used to close persistent LOBs
10555
+ that have not been streamed to completion.
10516
10556
10517
- A Readable Lob object starts out in paused mode. If a ' data' event
10557
+ A Readable Lob object starts out in paused mode. If a ` data` event
10518
10558
handler is added, or the Lob is piped to a Writeable stream, then the
10519
10559
Lob switches to flowing mode.
10520
10560
@@ -10525,7 +10565,7 @@ emitting `data` events.
10525
10565
10526
10566
Similarly, a Readable Lob operating in the paused mode can be switched
10527
10567
to flowing mode by calling `resume()`. It will then start emitting
10528
- ' data' events again.
10568
+ ` data` events again.
10529
10569
10530
10570
#### Writeable Lobs
10531
10571
@@ -10538,11 +10578,9 @@ resources. If the Lob is being piped into, then the `write()` and
10538
10578
Writeable Lobs also have events, see the [Node.js Stream][16]
10539
10579
documentation.
10540
10580
10541
- At the conclusion of streaming into a Writeable Lob, the `close` event
10542
- will occur. It is recommended to put logic such as committing and
10543
- releasing connections in this event (or after it occurs). See
10544
- [lobinsert2.js][51]. It is also recommended that persistent LOBs not
10545
- use the `finish` event handler for cleanup.
10581
+ At the conclusion of streaming into a Writeable Lob, the `finish` event will
10582
+ occur. It is recommended to put logic such as committing and releasing
10583
+ connections in this event (or after it occurs). See [lobinsert2.js][51].
10546
10584
10547
10585
### <a name="lobinsertdiscussion"></a> 17.4 Using RETURNING INTO to Insert into LOBs
10548
10586
@@ -10566,7 +10604,7 @@ if (result.rowsAffected != 1 || result.outBinds.lobbv.length != 1) {
10566
10604
10567
10605
const doInsert = new Promise((resolve, reject) => {
10568
10606
const lob = result.outBinds.lobbv[0];
10569
- lob.on('close ', async () => {
10607
+ lob.on('finish ', async () => {
10570
10608
await connection.commit(); // all data is loaded so we can commit it
10571
10609
});
10572
10610
lob.on('error', async (err) => {
@@ -10587,7 +10625,7 @@ await doInsert;
10587
10625
10588
10626
This example streams from a file into the table. When the data has
10589
10627
been completely streamed, the Lob is automatically closed and the
10590
- ' close' event triggered. At this point the data can be committed.
10628
+ ` close` event triggered. At this point the data can be committed.
10591
10629
10592
10630
See [lobinsert2.js][51] for the full example.
10593
10631
@@ -10610,7 +10648,7 @@ the stream, persistent LOBs are automatically closed.
10610
10648
Lobs returned from the database that are not streamed can be passed
10611
10649
back to the database as IN binds for PL/SQL blocks, for `INSERT`, or
10612
10650
for `UPDATE` statements. The Lobs should then be closed with
10613
- [`lob.close ()`](#lobclose ). If they are passed as IN OUT binds, they
10651
+ [`lob.destroy ()`](#lobdestroy ). If they are passed as IN OUT binds, they
10614
10652
will be automatically closed and the execution
10615
10653
[`outBinds`](#execoutbinds) property will contain the updated Lob.
10616
10654
@@ -10674,7 +10712,7 @@ if (lob.type === oracledb.CLOB) {
10674
10712
}
10675
10713
10676
10714
lob.on('error', function(err) { cb(err); });
10677
- lob.on('close ', function() { cb(null); }); // all done. The Lob is automatically closed.
10715
+ lob.on('end ', function() { cb(null); }); // all done. The Lob is automatically closed.
10678
10716
10679
10717
const outStream = fs.createWriteStream('myoutput.txt');
10680
10718
outStream.on('error', function(err) { cb(err); });
@@ -10699,7 +10737,7 @@ let str = "";
10699
10737
10700
10738
lob.setEncoding('utf8'); // set the encoding so we get a 'string' not a 'buffer'
10701
10739
lob.on('error', function(err) { cb(err); });
10702
- lob.on('close ', function() { cb(null); }); // all done. The Lob is automatically closed.
10740
+ lob.on('end ', function() { cb(null); }); // all done. The Lob is automatically closed.
10703
10741
lob.on('data', function(chunk) {
10704
10742
str += chunk; // or use Buffer.concat() for BLOBS
10705
10743
});
@@ -10710,7 +10748,7 @@ lob.on('end', function() {
10710
10748
```
10711
10749
10712
10750
Node-oracledb's [`lob.pieceSize`](#proplobpiecesize) can be used to
10713
- control the number of bytes retrieved for each readable ' data' event.
10751
+ control the number of bytes retrieved for each readable ` data` event.
10714
10752
This sets the number of bytes (for BLOBs) or characters (for CLOBs).
10715
10753
The default is [`lob.chunkSize`](#proplobchunksize). The
10716
10754
recommendation is for it to be a multiple of `chunkSize`.
@@ -10729,7 +10767,7 @@ statement IN binds, however the `RETURNING INTO` method shown above
10729
10767
will be more efficient.
10730
10768
10731
10769
Lobs from `createLob()` will use space in the temporary tablespace
10732
- until [`lob.close ()`](#lobclose ) is called. Database Administrators
10770
+ until [`lob.destroy ()`](#lobdestroy ) is called. Database Administrators
10733
10771
can track this usage by querying [`V$TEMPORARY_LOBS`][13].
10734
10772
10735
10773
#### Passing a Lob Into PL/SQL
@@ -10774,10 +10812,10 @@ const result = await connection.execute(
10774
10812
```
10775
10813
10776
10814
When the temporary LOB is no longer needed, it must be closed with
10777
- [`lob.close ()`](#lobclose ):
10815
+ [`lob.destroy ()`](#lobdestroy ):
10778
10816
10779
10817
```javascript
10780
- await templob.close ();
10818
+ await templob.destroy ();
10781
10819
```
10782
10820
10783
10821
### <a name="closinglobs"></a> 17.7 Closing Lobs
@@ -10787,25 +10825,16 @@ tablespace storage used by a temporary LOB is released. Once a Lob is
10787
10825
closed, it can no longer be bound or used for streaming.
10788
10826
10789
10827
Lobs created with [`createLob()`](#connectioncreatelob) should be
10790
- explicitly closed with [`lob.close ()`](#lobclose ).
10828
+ explicitly closed with [`lob.destroy ()`](#lobdestroy ).
10791
10829
10792
10830
Persistent or temporary Lobs returned from the database should be
10793
- closed with `lob.close ()` unless they have been automatically closed.
10831
+ closed with `lob.destroy ()` unless they have been automatically closed.
10794
10832
Automatic closing of returned Lobs occurs when:
10795
10833
10796
10834
- streaming has completed
10797
10835
- a stream error occurs
10798
10836
- the Lob was used as the source for an IN OUT bind
10799
10837
10800
- If you try to close a Lob being used for streaming you will get the
10801
- error *NJS-023: concurrent operations on a Lob are not allowed*.
10802
-
10803
- The connection must be open when calling `lob.close()` on a temporary
10804
- LOB.
10805
-
10806
- The `lob.close()` method emits the [Node.js Stream][16] 'close' event
10807
- unless the Lob has already been closed explicitly or automatically.
10808
-
10809
10838
## <a name="jsondatatype"></a> 18. Oracle Database JSON Data type
10810
10839
10811
10840
Oracle Database 12.1.0.2 introduced native support for JSON data. You
@@ -14449,6 +14478,18 @@ When upgrading from node-oracledb version 4.0 to version 4.1:
14449
14478
- Note that the default for [`oracledb.events`](#propdbevents) has reverted to
14450
14479
*false*. If you relied on it being *true*, then explicitly set it.
14451
14480
14481
+ ### <a name="migratev41v42"></a> 33.7 Migrating from node-oracledb 4.1 to node-oracledb 4.2
14482
+
14483
+ - Review the [CHANGELOG][83] and take advantage of new features.
14484
+
14485
+ - Review the updated Lob stream documentation. The best practice is to use the
14486
+ `end` event (for readable streams) and `finish` event (for writeable streams)
14487
+ instead of depending on the `close` event. Applications should migrate to the
14488
+ Node.js 8 [`destroy()`](#lobdestroy) method instead of the deprecated
14489
+ node-oracledb [`close()`](#lobclose) method. Note that unlike `close()`, the
14490
+ `destroy()` method does not take a callback parameter. If `destroy()` is
14491
+ given an error argument, an `error` event is emitted with this error.
14492
+
14452
14493
## <a name="otherresources"></a> 34. Useful Resources for Node-oracledb
14453
14494
14454
14495
Node-oracledb can be installed on the pre-built [*Database App Development
0 commit comments