Skip to content

Commit fc8bdba

Browse files
committed
Some small doc changes based on user issues and questions
1 parent e236538 commit fc8bdba

File tree

1 file changed

+66
-13
lines changed

1 file changed

+66
-13
lines changed

doc/api.md

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,15 +2614,29 @@ sales =
26142614
The `tnsnames.ora` file can be in a default location such as
26152615
`$ORACLE_HOME/network/admin/tnsnames.ora` or
26162616
`/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.
26182621
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).
26222622
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).
26262640
26272641
#### <a name="notjdbc"></a> 8.1.3 JDBC and Node-oracledb Connection Strings Compared
26282642
@@ -3580,7 +3594,9 @@ connection.execute(
35803594
```
35813595
35823596
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.
35843600
35853601
The metadata is an array of objects, one per column. By default each
35863602
object has a `name` attribute:
@@ -3723,7 +3739,7 @@ connection.execute(
37233739
```
37243740
37253741
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:
37273743
37283744
```sql
37293745
CREATE OR REPLACE TRIGGER my_logon_trigger
@@ -4749,7 +4765,7 @@ conn.execute(
47494765
});
47504766
```
47514767
4752-
When the LOB is no longer needed, it should be closed
4768+
When the LOB is no longer needed, it must be closed
47534769
with [`lob.close()`](#lobclose):
47544770
47554771
```javascript
@@ -4911,8 +4927,8 @@ text of the statement. Bind parameters are also called bind
49114927
variables.
49124928
49134929
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.
49164932
49174933
Inserted data that is bound is passed to the database separately from
49184934
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`
51465162
clause, and no duplication is allowed between bind variables in the
51475163
DML section and the `RETURNING` section of the statement.
51485164
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:
51505203
51515204
```javascript
51525205
var oracledb = require('oracledb');

0 commit comments

Comments
 (0)