No data being stored in IBM Db2 (using dashDB nodes)

For a school project I'm trying to develop an app that parses an RSS feed, runs a sentiment analysis on the headlines, and then stores the headlines in different tables according to keywords in their headlines. In the tables I have three columns set up - Headline, Sentiment, URL.

I'm basically certain that my node-RED app is connected to my IBM Db2 because I was having a problem with connection limits which was showing an error both on my node-RED debug window and in my IBM Db2 instance, but nothing is being stored in any of my tables when I deploy my app.

Here's a screenshot of my flow.

My function node has the following code in it:

msg.payload =
HEADLINE : msg.payload,
SENTIMENT : msg.sentiment.score,
URL : msg.topic
return msg;

And a screenshot of my switch node:

In my dashDB out nodes I have the table set as MCF67624.DRONE (with drone being replaced by whichever table the node is connecting to. I wasn't sure whether I just had to enter the table name or format it like SCHEMA.TABLE but neither has worked so far.

Another possibility I considered is that maybe I'm storing the information as the wrong data type in the table? I have tried storing the Headline and URL information as CHAR, VARBINARY and BLOB and no luck so far with any, and I've had the sentiment being stored as an integer.

I've tried to be as specific as possible so I hope this is a good question, I've done a lot of googling and can't seem to find a simple tutorial on how to do this. I've read the info in node-RED itself about the dashDB node and I feel like I'm doing everything necessary but clearly I'm missing something.

Any help is so so appreciated.

Look at where you store the sentiment. And look at the switch - you check payload contains a string value but payload was set to an object in the function.

Attach debug nodes to before the switch and after. You should see the message doesn't get past the switch.

Note, some of what I say is guess work as you haven't posted any debug data nor have you posted your flow.

I attached a debug node after the switch and got nothing, and then after the function node in front of the switch and got output, so you're absolutely right that it's not getting past the switch. Sorry for not posting debug data, I've never used these forums before and didn't think to include it!

Is there a change I could make to the function node that would allow me to add the categories I need for my column headings but not make msg.payload into an object, so I can still check for a string?

And what would be the correct data types to store the three pieces of information as in my tables?

Thank you so much just for the help you've already given me though, I never would have realised that there was a problem with setting msg.payload to an object.

There is no problem setting payload to an object. That is a very normal operation. The issue is treating payload as a string in your switch.

Which property of the payload (.HEADLINE? .SENTIMENT? .URL?) are you looking for these strings? Can't to change the switch to look inside payload.HEADLINE?

So what I've actually done is just change the order, so the switch node comes directly after the sentiment node and then between the switch and each dashDB node is an identical function and it is now storing information in the database. Thank you so much for pointing out where the flow was getting disrupted, I could not have solved this without you! I really really appreciate it. I've marked your first reply as the solution.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.