@@ -2614,15 +2614,29 @@ sales =
2614
2614
The ` tnsnames .ora ` file can be in a default location such as
2615
2615
` $ORACLE_HOME / network/ admin/ tnsnames .ora ` or
2616
2616
` / etc/ tnsnames .ora ` . Alternatively set the ` TNS_ADMIN ` environment
2617
- variable and put the file in ` $TNS_ADMIN / tnsnames .ora ` .
2617
+ variable and put the file in ` $TNS_ADMIN / tnsnames .ora ` . For more
2618
+ information on ` tnsnames .ora ` files see
2619
+ [General Syntax of tnsnames.ora](https://docs.oracle.com/database/122/NETRF/local-naming-parameters-in-tnsnames-ora-file.htm#NETRF1361) in
2620
+ the Oracle documentation.
2618
2621
2619
- Applications that request [DRCP](#drcp) connections, for example where
2620
- the ` tnsnames .ora ` connection description contains ` (SERVER = POOLED )` ,
2621
- must use local [Connection Pooling](#connpooling).
2622
2622
2623
- For more information on ` tnsnames .ora ` files see
2624
- [General Syntax of tnsnames.ora](https://docs.oracle.com/database/122/NETRF/local-naming-parameters-in-tnsnames-ora-file.htm#NETRF1361)
2625
- in the Oracle documentation.
2623
+ Full connection strings can be embedded in applications:
2624
+
2625
+ ` ` ` javascript
2626
+ var oracledb = require (' oracledb' );
2627
+
2628
+ oracledb .getConnection (
2629
+ {
2630
+ user : " hr" ,
2631
+ password : " welcome" ,
2632
+ connectString : " (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mymachine.example.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))"
2633
+ },
2634
+ . . .
2635
+ ` ` `
2636
+
2637
+ Applications that request [DRCP](#drcp) connections, for example where
2638
+ the connection description contains ` (SERVER = POOLED )` , must use
2639
+ local [Connection Pooling](#connpooling).
2626
2640
2627
2641
#### <a name="notjdbc"></a> 8.1.3 JDBC and Node-oracledb Connection Strings Compared
2628
2642
@@ -3580,7 +3594,9 @@ connection.execute(
3580
3594
` ` `
3581
3595
3582
3596
When using a [` ResultSet` ](#resultsetclass), metadata is also
3583
- available in [` result .resultSet .metaData ` ](#rsmetadata).
3597
+ available in [` result .resultSet .metaData ` ](#rsmetadata). For queries
3598
+ using [` queryStream ()` ](#querystream), metadata is available via the
3599
+ ` metadata` event.
3584
3600
3585
3601
The metadata is an array of objects, one per column. By default each
3586
3602
object has a ` name` attribute:
@@ -3723,7 +3739,7 @@ connection.execute(
3723
3739
` ` `
3724
3740
3725
3741
To do this without requiring the overhead of a 'round trip' to execute
3726
- the ` ALTER ` statement, you could use a trigger:
3742
+ the ` ALTER ` statement, you could use a PL/SQL trigger:
3727
3743
3728
3744
` ` ` sql
3729
3745
CREATE OR REPLACE TRIGGER my_logon_trigger
@@ -4749,7 +4765,7 @@ conn.execute(
4749
4765
});
4750
4766
` ` `
4751
4767
4752
- When the LOB is no longer needed, it should be closed
4768
+ When the LOB is no longer needed, it must be closed
4753
4769
with [` lob .close ()` ](#lobclose):
4754
4770
4755
4771
` ` ` javascript
@@ -4911,8 +4927,8 @@ text of the statement. Bind parameters are also called bind
4911
4927
variables.
4912
4928
4913
4929
Using bind parameters is recommended in preference to constructing SQL
4914
- or PL/SQL statements by string concatenation. This is for performance
4915
- and security.
4930
+ or PL/SQL statements by string concatenation or template literals.
4931
+ This is for performance and security.
4916
4932
4917
4933
Inserted data that is bound is passed to the database separately from
4918
4934
the statement text. It can never be executed. This means there is no
@@ -5146,7 +5162,44 @@ No duplicate binds are allowed in a DML statement with a `RETURNING`
5146
5162
clause, and no duplication is allowed between bind variables in the
5147
5163
DML section and the ` RETURNING ` section of the statement.
5148
5164
5149
- An example of DML RETURNING binds is:
5165
+ One common use case is to return an 'auto incremented' key values.
5166
+ Given a table:
5167
+
5168
+ ` ` ` sql
5169
+ CREATE TABLE itinerary (
5170
+ id NUMBER (11 ) GENERATED BY DEFAULT ON NULL AS IDENTITY (START WITH 1 ),
5171
+ city VARCHAR2 (40 ))
5172
+ ` ` `
5173
+
5174
+ (Note: versions of Oracle Database prior to 12.1 use a SEQUENCE and
5175
+ PL/SQL TRIGGER to auto generate key values.)
5176
+
5177
+ The auto-generated key values can be returned like:
5178
+
5179
+ ` ` ` javascript
5180
+ var oracledb = require (' oracledb' );
5181
+ . . .
5182
+ connection .execute (
5183
+ " INSERT INTO itinerary (city) VALUES (:cbv)"
5184
+ + " RETURNING id INTO :idbv" ,
5185
+ {
5186
+ cbv: " Melbourne" ,
5187
+ idbv: { type: oracledb .NUMBER , dir: oracledb .BIND_OUT }
5188
+ },
5189
+ function (err , result )
5190
+ {
5191
+ if (err) { console .error (err); return ; }
5192
+ console .log (result .outBinds );
5193
+ });
5194
+ ` ` `
5195
+
5196
+ This would produce output similar to:
5197
+
5198
+ ` ` `
5199
+ { idbv: [ 1 ] }
5200
+ ` ` `
5201
+
5202
+ A second example of DML RETURNING binds is:
5150
5203
5151
5204
` ` ` javascript
5152
5205
var oracledb = require (' oracledb' );
0 commit comments