Regarding oracle error

Hi Everyone, I am new to Node-Red, and I am storing the oracle details(like config) inside function node
"oracledbuser": "username",
"oracledbpassword": "password",
"oracledbconstring": "IP addr:portnumber",
"oracledbschema": "schema name",
"tablevariable": "tablename",
I am setting this as global.set and in other flow if i try to retrieve the table as global.get,
var data = global.get('configvar').oracledbschema + . + global.get('configvar').tablevariable;
I am getting the below error
"TypeError: Cannot read property 'oracledbuser' of undefined"
Please help anyone

The error is complaining about oracledbuser, but the code you've shared doesn't mention that property... So I assume you have not shared the full code. That makes it tricky because if you have a typo in the code you haven't shared, we won't be able to spot it.

The other thing to check is whether you are sure you have injected the values into global context before this flow runs.

1 Like

Even I am facing the same error. I have used the following code

var config = {

"oracledbuser": "system",
"oracledbpassword": "password",
"oracledbconstring": "hostname:portno",
"oracledbschema": "schemaname"

// "contactTesting":false


return msg;

You have not showed us the code where the error is shown. Also you have not answered whether you have checked that the code that accesses the global data has been run when you the code trying to access it is run.
In function nodes the node.warn() function can be used to help debug what is going on, the results are shown in the debug panel, so after you set the global data you could insert
node.warn("Data written " + global.get('appconfig').oracledbuser)
and after you fetch it you could insert a similar line to show the value fetched.

1 Like

Hi Colin, the node-red install in my machine doesn't contain the global context file. I am working on fixing that. Maybe that is the cause for my issue.

I don't understand what you mean by the global context file, but I don't think it is anything to do with your problem.

I can’t remember if context is by default stored in memory or the file system. You should check your settings.js file to see what it is.

@Divya @Ramya are you both working on the same problem here?

Neither of you have shown how you are trying to use these context values as I pointed out in my first reply. Without that we won't make any progress.

[{"id":"9a8d0eaa.13183","type":"tab","label":"Pass Config data","disabled":false,"info":""},{"id":"472333ed.878fdc","type":"debug","z":"9a8d0eaa.13183","name":"Output","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":930,"y":440,"wires":[]},{"id":"e2ab9f25.2c4468","type":"function","z":"9a8d0eaa.13183","name":"Set Global config data","func":"\nvar config = {\n \n \"oracledbuser\": \"username\",\n \"oracledbpassword\": \"password\",\n \"oracledbconstring\": \"hostname:portno\",\n \"oracledbschema\": \"schemaName\",\n \"tableA\": \"A\",\n \"contactTesting\":false\n}\n\n\nglobal.set('appconfig',config);\n\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":440,"wires":[["472333ed.878fdc"]]},{"id":"a337f083.a6afb8","type":"inject","z":"9a8d0eaa.13183","name":"Inject Config","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":590,"y":280,"wires":[["e2ab9f25.2c4468"]]},{"id":"6cca3160.aec958","type":"link in","z":"9a8d0eaa.13183","name":"Set Config","links":["23b54cad.2929f4","34d6a4f9.54829c","4bf382f8.75e14c","4f14999c.9e7a78","6f812b92.0ed244","7079efa7.d28d","78dc19a0.e77068","94ff8bbf.5c4238","9cb671ce.d9d89","9d7f0d52.8079d","b94f2961.6e82d8","baf0ddb0.57424","bc93b0eb.1e278","beb197bb.171b18","d7bbb3.503e845","f7440dac.711ba","6baec3ac.2c6254"],"x":415,"y":440,"wires":[["e2ab9f25.2c4468"]]}]

The above flow is the configuration flow that I am linking to all my other flows. Here, I wanted to insert some data to my database via the custom node. Where, all the flows works in others system but not working in mine. I am using Ubuntu 16.04 LTS.
I am using a custom node which helps in connecting my node-red API with the Oracle DB. Do we have any other node in node-red which does this job?

If we do have a node-red node to connect to oracle-db, then I don't think there's a use of the custom node.


<script type="text/javascript">
    RED.nodes.registerType('oracle-db', {
        category: 'Custom nodes',
        color: '#97CC36',
        defaults: {
            name: {
                value: ""
        inputs: 1,
        outputs: 1,
        icon: "white-globe.png",
        label: function () {
            return || "Oracle DB";

<script type="text/x-red" data-template-name="oracle-db">


    <div class="form-row">
        <label for="node-input-name"><i class="icon-tag"></i> Name</label>
        <input type="text" id="node-input-name" placeholder="Name">

<script type="text/x-red" data-help-name="oracle-db">
    <p>Node to Query Data from Oracle Database</p>


 var oracledb = require('oracledb');

 module.exports = function (RED) {

         function OracleDB(config) {

             RED.nodes.createNode(this, config);
             var node = this;

             node.on('input', function (msg) {
                     //  console.log(config.user);
                     //  console.log(config.password);
                     //  console.log(config.connect);
                     //  console.log(msg.payload.query);

                     const global = node.context().global;
                     const config = global.get('appconfig');

                     if (!msg.payload.query) {
                         node.error("Input Query Missing in Payload");
                             fill: "red",
                             shape: "dot",
                             text: "Input Query Missing in Payload"
                         return false;
                     if (!config.oracledbuser || !config.oracledbpassword || !config.oracledbconstring) {
                             node.error(" Node Input Missing");
                                 fill: "red",
                                 shape: "dot",
                                 text: "Node Input Missing"
                             return false;

                                 user: config.oracledbuser,
                                 password: config.oracledbpassword,
                                 connectString: config.oracledbconstring
                             function (err, connection) {
                                 if (err) {
                                     fill: "green",
                                     shape: "dot",
                                     text: "connected"

                                 var options = {
                                     autoCommit: true

                                     msg.payload.query, [],
                                     //  params,
                                     function (err, result) {
                                         if (err) {
                                         var records = result.rows;
                                         msg.responsedata = records ? records : null;
                                         msg.result = result;

                 function doRelease(connection) {
                         function (err) {
                             if (err)

             RED.nodes.registerType("oracle-db", OracleDB);

These are the custom node files that I am using.

I reinstalled oracle and node-red. It works fine now. Thanks for the guidance.