|
| 1 | +Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + |
| 3 | +#TimesTen Node.js Samples |
| 4 | + |
| 5 | +This folder contains Node.js samples that illustrate database connection and operations using the node-oracledb driver against TimesTen databases. |
| 6 | + |
| 7 | +##Software & Platform Support |
| 8 | +The following table describes the tested operating systems, node-oracledb driver and TimesTen software versions. |
| 9 | + |
| 10 | +OS | Node.js Version | node-oracledb Driver Version | TimesTen Client Driver | TimesTen Direct Driver |
| 11 | +------------- | ------- | ------------- | ------------ | ------ |
| 12 | +Linux 64-bit | 12.7.0 |4.0.1 | 18.1.3.1.0+ | 18.1.3.1.0+ |
| 13 | +macOS | 12.7.0 |4.0.1 | 18.1.3.1.0+ | N/A |
| 14 | +MS Windows 64-bit | 12.7.0 | 4.0.1 | 18.1.3.1.0+ | N/A |
| 15 | + |
| 16 | +**NOTE**: Access to TimesTen Databases on any supported TimesTen server platforms can be achieved using the TimesTen client driver from any of the platforms listed above. For more information on supported TimesTen platforms, see [TimesTen Release Notes](https://docs.oracle.com/database/timesten-18.1/TTREL/toc.htm). |
| 17 | + |
| 18 | + |
| 19 | +## PRE-REQUISITES |
| 20 | + |
| 21 | +1. Node.js language is installed. |
| 22 | +2. The node-oracledb driver is installed. |
| 23 | +3. A TimesTen database is created and data source is setup to access that database. |
| 24 | +4. Environment to access Node.js, node-oracledb driver and TimesTen data source are set up (i.e. the TimesTen environment script ttenv.sh/ttenv.csh has been executed) |
| 25 | + |
| 26 | +For more information on setup, see [TimesTen In-Memory Database Open Source Languages Support Guide](https://docs.oracle.com/database/timesten-18.1/TTOSL/toc.htm). |
| 27 | + |
| 28 | +## Known Problems and Limitations |
| 29 | +* REF CURSORs are currently not supported. |
| 30 | +* Using the NVARCHAR/NCHAR data types for input parameters in a PL/SQL procedure is currently not supported. |
| 31 | +* Large objects (LOBs) are currently not supported. |
| 32 | +* DML statements with RETURN INTO are currently not supported. |
| 33 | +* The value returned for the sub-second field of a PL/SQL output parameter of type Timestamp may be incorrect. |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | +## Node.js sample programs |
| 38 | +### Download Samples |
| 39 | + |
| 40 | +Node.js sample programs to access TimesTen databases can be downloaded from [Oracle/oracle-timesten-samples/languages/nodejs on github](https://github.com/oracle/oracle-timesten-samples/tree/master/languages/nodejs). Command-line command such as "git clone" can be used for github download. For example, |
| 41 | + |
| 42 | +``` |
| 43 | +% git clone https://github.com/oracle/oracle-timesten-samples |
| 44 | +``` |
| 45 | + |
| 46 | +Once the samples are downloaded locally, you can change to languages/nodejs subdirectory and run the samples directly from the local machine. Descriptions of the sample programs and examples of how to run them are below. |
| 47 | + |
| 48 | +###simple.js |
| 49 | + |
| 50 | +This simple sample program connects to a TimesTen database and performs the following operations: |
| 51 | + |
| 52 | +* creates a table named Employees |
| 53 | +* inserts 3 rows to the table |
| 54 | +* select the rows from the table |
| 55 | +* drops the table |
| 56 | +* disconnects from the database. |
| 57 | + |
| 58 | +Example: |
| 59 | + |
| 60 | +``` |
| 61 | +% node simple.js -u username -p password |
| 62 | +Table has been created |
| 63 | +Inserted 3 employees into the table |
| 64 | +Selected employee: ROBERT ROBERTSON |
| 65 | +Selected employee: ANDY ANDREWS |
| 66 | +Selected employee: MICHAEL MICHAELSON |
| 67 | +Table has been dropped |
| 68 | +Connection has been released |
| 69 | +``` |
| 70 | + |
| 71 | + |
| 72 | +### sql.js |
| 73 | +The sql sample program connects to a TimesTen database and performs the following operations: |
| 74 | + |
| 75 | + |
| 76 | +* Creates a table called "vpn_users" |
| 77 | +* Populates the table with records |
| 78 | +* Performs a number of Selects, Updates and Deletes against the table |
| 79 | +* Drops the table |
| 80 | +* Disconnects from the database |
| 81 | + |
| 82 | +Example: |
| 83 | + |
| 84 | +``` |
| 85 | +% node sql.js -u username -p password |
| 86 | +Table has been created |
| 87 | +Populating table |
| 88 | + Inserted 10 rows |
| 89 | + Inserted 20 rows |
| 90 | + Inserted 30 rows |
| 91 | + Inserted 40 rows |
| 92 | + Inserted 50 rows |
| 93 | + Inserted 60 rows |
| 94 | + Inserted 70 rows |
| 95 | + Inserted 80 rows |
| 96 | + Inserted 90 rows |
| 97 | + Inserted 100 rows |
| 98 | +Performing selects |
| 99 | + select(ed) 10 rows |
| 100 | + select(ed) 20 rows |
| 101 | + select(ed) 30 rows |
| 102 | + select(ed) 40 rows |
| 103 | + select(ed) 50 rows |
| 104 | + select(ed) 60 rows |
| 105 | + select(ed) 70 rows |
| 106 | + select(ed) 80 rows |
| 107 | +Performing updates |
| 108 | + update(ed) 10 rows |
| 109 | + update(ed) 20 rows |
| 110 | +Performing deletes |
| 111 | + delete(ed) 10 rows |
| 112 | + delete(ed) 20 rows |
| 113 | +Connection has been released |
| 114 | +``` |
| 115 | +###queriesAndPlsql.js |
| 116 | + |
| 117 | +The queriesAndPlsql sample program connects to a TimesTen database and performs a number of database operations with PL/SQL: |
| 118 | + |
| 119 | + |
| 120 | +* Creates a table named "items" |
| 121 | +* Populates the table |
| 122 | +* Performs Selects fetching 100 rows |
| 123 | +* Calls a PL/SQL procedure to update a row |
| 124 | +* Calls a PL/SQL procedure to delete a row |
| 125 | +* Drops the table |
| 126 | +* Disconnects from the database |
| 127 | + |
| 128 | +Example: |
| 129 | + |
| 130 | +``` |
| 131 | +% node queriesAndPlsql.js -u username -p password |
| 132 | +Table has been created |
| 133 | +Inserting with executeMany ... |
| 134 | + 100 Registries added |
| 135 | +Select some rows with one select ... |
| 136 | + 20 Rows have been fetched and iterated |
| 137 | +Updating a row using an anonymous block ... |
| 138 | + Value before update: [ 'descr_0' ] |
| 139 | + Value after update: [ 'updated description' ] |
| 140 | +Delete a row using an anonymous block ... |
| 141 | + Rows after delete = [ 99 ] |
| 142 | +Connection has been released |
| 143 | +
|
| 144 | +``` |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | +## Documentation |
| 149 | +You can find the online documentation for Oracle TimesTen In-Memory Database in the [Documentation Library](https://docs.oracle.com/database/timesten-18.1/). Online documenation for the node-oracledb driver can be found [here](https://oracle.github.io/node-oracledb/doc/api.html). |
0 commit comments