Skip to content

Commit baeb2f2

Browse files
committed
Add doc for new metaData attribute
1 parent fc4c623 commit baeb2f2

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

doc/api.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ limitations under the License.
7575
7. [SQL Execution](#sqlexecution)
7676
- 7.1 [SELECT Statements](#select)
7777
- 7.1.1 [Query Output Formats](#queryoutputformats)
78-
- 7.1.2 [Result Type Mapping](#typemap)
79-
- 7.1.3 [Statement Caching](#stmtcache)
78+
- 7.1.2 [Query Column Metadata](#querymeta)
79+
- 7.1.3 [Result Type Mapping](#typemap)
80+
- 7.1.4 [Statement Caching](#stmtcache)
8081
- 7.2 [Bind Parameters for Prepared Statements](#bind)
8182
- 7.2.1 [IN Bind Parameters](#inbind)
8283
- 7.2.2 [OUT and IN OUT Bind Parameters](#outbind)
@@ -1050,6 +1051,13 @@ one single row. The number of rows returned is limited to the
10501051
`maxRows` configuration property of the *Oracledb* object, although
10511052
this may be overridden in any `execute()` call.
10521053

1054+
```
1055+
array metaData
1056+
```
1057+
1058+
For `SELECT` statements, this contains an array of column names for
1059+
the select list. For non queries, this property is undefined.
1060+
10531061
```
10541062
Array/object outBinds
10551063
```
@@ -1355,7 +1363,38 @@ property names are uppercase. This is the default casing behavior for
13551363
Oracle client programs when a database table is created with
13561364
case-insensitive column names.
13571365

1358-
### <a name="typemap"></a> 7.1.2 Result Type Mapping
1366+
### <a name="querymeta"></a> 7.1.2 Query Column Metadata
1367+
1368+
The column names of a query are returned in the
1369+
[`execute()`](#execute) callback `result` parameter:
1370+
1371+
```javascript
1372+
connection.execute("SELECT department_id, department_name "
1373+
+ "FROM departments "
1374+
+ "WHERE department_id = :did",
1375+
[180],
1376+
function(err, result)
1377+
{
1378+
if (err) {
1379+
console.error(err.message);
1380+
return;
1381+
}
1382+
console.log(result.metaData);
1383+
});
1384+
```
1385+
1386+
The output is an array of objects, one per column. Each object has a
1387+
`name` attribute:
1388+
1389+
```
1390+
[ { name: 'DEPARTMENT_ID' }, { name: 'DEPARTMENT_NAME' } ]
1391+
```
1392+
1393+
The names are in uppercase. This is the default casing behavior for
1394+
Oracle client programs when a database table is created with
1395+
case-insensitive column names.
1396+
1397+
### <a name="typemap"></a> 7.1.3 Result Type Mapping
13591398

13601399
Oracle character, number and date columns can be selected. Data types
13611400
that are currently unsupported give a "datatype is not supported"
@@ -1377,7 +1416,7 @@ Query result type mappings for Oracle Database types to JavaScript types are:
13771416
When binding a JavaScript Date value in an `INSERT` statement, the date is also inserted as `TIMESTAMP WITH
13781417
LOCAL TIMEZONE` using OCIDateTime.
13791418

1380-
### <a name="stmtcache"></a> 7.1.3 Statement Caching
1419+
### <a name="stmtcache"></a> 7.1.4 Statement Caching
13811420

13821421
Node-oracledb uses the
13831422
[Oracle OCI statement cache](https://docs.oracle.com/database/121/LNOCI/oci09adv.htm#i471377)

0 commit comments

Comments
 (0)