node-oracledb/examples
Sharad Chandran R e4a261d78a Add support for binary vector (Oracle Database 23ai feature) and eslint fixes in code 2024-07-15 13:05:18 +05:30
..
README.md Documentation, Test and Example updates for 6.6 release 2024-06-21 17:36:23 +05:30
aqmulti.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
aqobject.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
aqoptions.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
aqraw.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
aqutil.js Update examples information 2024-01-30 16:53:52 +05:30
azureProviderSample.js Add Centralized Configuration Provider support (Oracle Database 23ai) 2024-07-15 12:59:20 +05:30
blobhttp.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
calltimeout.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
clobexample.txt Move more links to http://oracle.github.io/node-oracledb/ 2018-03-27 16:12:28 +11:00
connect.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
connectionpool.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
cqn1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
cqn2.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
date_timestamp1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
date_timestamp2.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
dbconfig.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
dbmsoutputgetline.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
dbmsoutputpipe.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
demodrop.js Thin mode support and new examples 2023-05-23 19:50:06 +05:30
demosetup.js Thin mode support and new examples 2023-05-23 19:50:06 +05:30
dmlrupd.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
em_batcherrors.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
em_dmlreturn1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
em_dmlreturn2.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
em_insert1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
em_insert2.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
em_plsql.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
em_rowcounts.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
endtoend.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
example.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
fuzzydinosaur.jpg Update examples for node-oracledb 1.0 2015-08-17 16:03:41 +10:00
impres.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
insert1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
insert2.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
lastinsertid.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
lobbinds.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
lobinsert1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
lobinsert2.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
lobinserttemp.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
lobplsqltemp.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
lobselect.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
lobstream1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
lobstream2.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
lowercasecolumns.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
metadata.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
ociProviderSample.js Add Centralized Configuration Provider support (Oracle Database 23ai) 2024-07-15 12:59:20 +05:30
plsqlarray.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
plsqlfunc.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
plsqlproc.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
plsqlrecord.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
plsqlrowtype.js Documentation, Test and Example updates for 6.6 release 2024-06-21 17:36:23 +05:30
plsqlvarrayrecord.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
raw.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
refcursor.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
refcursortoquerystream.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
resultset1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
resultset2.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
resultset3.js Latest test updates and new examples added 2024-03-11 17:10:26 +05:30
resultsettoquerystream.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
rowlimit.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
sampleazuretokenauth.js Documentation, test and example updates 2023-11-09 20:14:00 +05:30
sampleocitokenauth.js Update examples information 2024-01-30 16:53:52 +05:30
select1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
select2.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
selectgeometry.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
selectjson.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
selectjsonblob.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
selectnestedcursor.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
selectobject.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
selectstream.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
selectvarray.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
sessionfixup.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
sessiontagging1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
sessiontagging2.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
soda1.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
soda2.js Add support for async iteration of SODA document cursors 2024-03-11 17:13:38 +05:30
typehandlerdate.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
typehandlernum.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
vectortype1.js Add support for binary vector (Oracle Database 23ai feature) and eslint fixes in code 2024-07-15 13:05:18 +05:30
vectortype2.js Add support for vector datatype with test case and formatting updates 2024-03-11 12:22:40 +05:30
version.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
webapp.js Added new env variable and automatic AQ table and queue for examples and test updates 2023-10-31 10:05:56 +05:30
xmltypeInDbObject.js Tighten test cases and examples 2024-07-15 12:14:40 +05:30

README.md

Node-oracledb Examples

The directory in node-oracledb's Github repository contains a lot of node-oracledb examples. Documentation is here.

To run the examples:

  • Install node-oracledb.

  • Ensure that you navigate to the examples directory in your terminal window or IDE, where you are running the samples.

  • Review dbconfig.js.

In your terminal window or IDE, set the following environment variables to provide credentials for the dbconfig.js file.

  • NODE_ORACLEDB_USER must be set to the database user.

  • NODE_ORACLEDB_PASSWORD must be set to the database password.

  • NODE_ORACLEDB_CONNECTIONSTRING must be set to the connection string that points to your database's location.

  • NODE_ORACLEDB_EXTERNALAUTH provides the options for enabling external authentication. Setting this environment variable to "true" will enable external authentication. To ensure external authentication works, firstly make sure the Oracle external authentication service is correctly configured. See Documentation for External Authentication for details.

  • NODE_ORACLEDB_DRIVER_MODE provides an option to set the 'Thin' or 'Thick' modes of node-oracledb. Setting this environment variable to "thick" will enable Thick mode. Setting it to "thin" will retain the Thin mode. The default mode is Thin.

  • NODE_ORACLEDB_WALLET_LOCATION must be set to the local directory name for the wallets that may be required for mutual TLS (mTLS) connections, especially to Oracle Cloud Autonomous Databases optionally. The wallet location can also be provided as a part of the database connect string.

  • NODE_ORACLEDB_WALLET_PASSWORD must set to the password for the wallets that may be required for mutual TLS (mTLS) connections, especially to Oracle Cloud Autonomous Databases.

  • NODE_ORACLEDB_CLIENT_LIB_DIR provides an optional path for the Oracle Client libraries to be used on Windows and macOS platforms, when using Thick mode in node-oracledb.

Review the examples and then run them individually. For example, to see what the file example.js does, use:

node example.js

After running the examples, the demonstration objects can be dropped with demodrop.js:

node demodrop.js

Many examples can be run in either node-oracledb Thin (the default) or Thick modes. Thin mode is a pure JavaScript implementation of node-oracledb. Setting the environment variable NODE_ORACLEDB_DRIVER_MODE to 'thick' will make examples use Thick mode.

Example Overview

If this is your first time with node-oracledb, start with example.js.

File Name Description
aqmulti.js Oracle Advanced Queuing (AQ) example passing multiple messages
aqobject.js Oracle Advanced Queuing (AQ) example passing an Oracle Database object
aqoptions.js Oracle Advanced Queuing (AQ) example setting options and message attributes
aqraw.js Basic Oracle Advanced Queuing (AQ) example passing text messages
aqutil.js Common file to setup the user credentials for all the Advanced Queuing (AQ) examples.
blobhttp.js Simple web app that streams an image
calltimeout.js Shows how to cancel a SQL statement if it doesn't complete in a specified time
connect.js Basic example for creating a standalone (non-pooled) connection
connectionpool.js Basic example creating a pool of connections
cqn1.js Basic Continuous Query Notification (CQN) example
cqn2.js Continuous Query Notification with notification grouping
date_timestamp1.js Show some basic DATE and TIMESTAMP behaviors
date_timestamp2.js Show some DATE and TIMESTAMP behaviors with timezones
dbconfig.js Common file used by examples for setting connection credentials
dbmsoutputgetline.js Show fetching DBMS_OUTPUT by binding buffers
dbmsoutputpipe.js Show fetching DBMS_OUTPUT by using a pipelined table
demodrop.js Drops the schema objects created by the examples
demosetup.js Used to create common schema objects for the examples
dmlrupd.js Example of DML RETURNING where multiple rows are matched
em_batcherrors.js executeMany() example showing handling data errors
em_dmlreturn1.js executeMany() example of DML RETURNING that returns single values
em_dmlreturn2.js executeMany() example of DML RETURNING that returns multiple values
em_insert1.js Array DML example using executeMany() with bind-by-name syntax
em_insert2.js Array DML example using executeMany() with bind by position
em_plsql.js executeMany() example calling PL/SQL multiple times with one call
em_rowcounts.js executeMany() example showing how to find the number of rows affected by each input row
endtoend.js Example showing setting tracing attributes
example.js Basic example showing creating a table, inserting multiple rows, and querying rows
impres.js Shows PL/SQL 'Implict Results' returning multiple query results from PL/SQL code.
insert1.js Basic example creating a table and inserting data. Shows DDL and DML
insert2.js Basic example showing auto commit behavior
lastinsertid.js Shows inserting a row and getting its ROWID.
lobbinds.js Demonstrates how to bind and query LOBs
lobinsert1.js Shows inserting a file into a CLOB column
lobinsert2.js Inserts text into a CLOB column using the RETURNING INTO method.
lobinserttemp.js Writes data to a Temporary CLOB and then inserts it into the database
lobplsqltemp.js Streams data into a Temporary CLOB and then passes it to PL/SQL
lobselect.js Shows basic, non-streaming CLOB and BLOB queries
lobstream1.js Shows how to stream LOBs to files
lobstream2.js Shows using Stream data events to fetch a CLOB
lowercasecolumns.js Shows how a type handler can convert column names to lower case
metadata.js Shows the metadata available after executing SELECT statements
plsqlarray.js Examples of binding PL/SQL "INDEX BY" tables
plsqlfunc.js How to call a PL/SQL function
plsqlproc.js How to call a PL/SQL procedure
plsqlrecord.js Shows binding of PL/SQL RECORDS
plsqlvarrayrecord.js Shows binding a VARRAY of RECORD in PL/SQL
plsqlrowtype.js Shows binding of PL/SQL %ROWTYPE object
raw.js Shows using a Buffer to insert and select a RAW
refcursor.js Shows using a ResultSet to fetch rows from a REF CURSOR
refcursortoquerystream.js Converts a REF CURSOR returned from execute() to a query stream.
resultset1.js Executes a query and uses a ResultSet to fetch rows with getRow()
resultset2.js Executes a query and uses a ResultSet to fetch batches of rows with getRows()
resultsettoquerystream.js Converts a ResultSet returned from execute() into a Readable Stream.
rowlimit.js Shows ways to limit the number of records fetched by queries
sampleazuretokenauth.js Shows connection pooling with Azure token based authentication.
sampleocitokenauth.js Shows connection pooling with OCI OAuth 2.0 token based authentication.
select1.js Executes a basic query without using a connection pool or ResultSet
select2.js Executes queries to show array and object output formats
selectgeometry.js Insert and query Oracle Spatial geometries
selectjson.js Shows some JSON features of Oracle Database 21c
selectjsonblob.js Shows how to use a BLOB as a JSON column store
selectobject.js Insert and query a named Oracle database object
selectnestedcursor.js Shows selecting from a nested cursor
selectstream.js Executes a basic query using a Readable Stream
selectvarray.js Shows inserting and selecting from a VARRAY column
sessionfixup.js Shows a pooled connection callback to efficiently set session state
sessiontagging1.js Simple pooled connection tagging for setting session state
sessiontagging2.js More complex example of pooled connection tagging for setting session state
soda1.js Basic Simple Oracle Document Access (SODA) example
typehandlerdate.js Show how a type handler can format a queried date in a locale-specific way
typehandlernum.js Show how a type handler can alter queried numbers
vectortype1.js Insert and query VECTOR columns.
vectortype2.js Insert data into VECTOR columns and verify vector operations.
version.js Shows the node-oracledb version attributes
webapp.js A simple web application using a connection pool
xmltypeInDbObject.js Work with XMLType data in DbObject (Thin mode only)