Skip to content

Latest commit

 

History

History

node-oracledb

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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