# Opcua client sqlite not working

**URL:** https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683
**Category:** Industrial
**Tags:** opcua
**Created:** [22 July 2024 20:45 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683 "2024-07-22T20:45:32Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![nathan1](https://avatars.discourse-cdn.com/v4/letter/n/8baadc/32.png) [@nathan1](https://discourse.nodered.org/u/nathan1)
#### Post date: [22 July 2024 20:45 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/1 "2024-07-22T20:45:32Z")

</div>

Hello,

I am currently working on creating a datalogger using OPCUA. For some reason, I'm unable to get the msg.payload into the sqlite, because it's saying that the payload is undefined. Could anyone help with this Issue?  
\*

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6dd03572bac4d348090b55716e357e64e051a44a.png)  
\*  
Thank you for your time.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [22 July 2024 21:14 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/2 "2024-07-22T21:14:35Z")

</div>

Welcome to the forum @nathan1

> [@nathan1](#):
>
> it's saying that the payload is undefined

It is saying that you are trying to access column named `undefined`. Use a debug node to see what is coming out of the write query function so that you can check what you are actually sending to the database.

---

<div class="post-metadata">

### Author: ![nathan1](https://avatars.discourse-cdn.com/v4/letter/n/8baadc/32.png) [@nathan1](https://discourse.nodered.org/u/nathan1)
#### Post date: [23 July 2024 13:35 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/3 "2024-07-23T13:35:58Z")

</div>

Hi @Colin,  
This is what I'm seeing:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/5/c54194edf6446f9192ff96fd9a2f48e30502ded8.png)  
This is my first time using Node-Red, I'm still a newbie.  
Thank you,  
Nathan

---

<div class="post-metadata">

### Author: ![nathan1](https://avatars.discourse-cdn.com/v4/letter/n/8baadc/32.png) [@nathan1](https://discourse.nodered.org/u/nathan1)
#### Post date: [23 July 2024 19:12 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/4 "2024-07-23T19:12:19Z")

</div>

> [@Colin](#):
>
> Use a debug node to see what is coming out of the write query function so that you can check what you are actually sending to the database.

Here's the writequery function:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/1/81dd95b79b7b2d1fc6023b9297239f0faba52688.png)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [23 July 2024 19:42 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/5 "2024-07-23T19:42:47Z")

</div>

msg.topic should be a string containing the query. Possibly something like  
`msg.topic = "INSERT INTO RANDOMNUM VALUES (" + x + ")"`  
Though I find it much easier to use this syntax for making complex strings

```auto
msg.topic = `INSERT INTO RANDOMNUM VALUES ( ${x} )`

```

Also make debug 3 output Complete Message so you can more easily see what is in the topic.  
In addition I recommend adding another debug node showing what is going _into_ the function to check that what you expect is there.

---

<div class="post-metadata">

### Author: ![nathan1](https://avatars.discourse-cdn.com/v4/letter/n/8baadc/32.png) [@nathan1](https://discourse.nodered.org/u/nathan1)
#### Post date: [24 July 2024 14:01 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/6 "2024-07-24T14:01:59Z")

</div>

Hi Colin,  
It seems that it's getting NULL into the writequery function. I'm not sure why since Debug3 is getting the correct message.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/2/b2e0309b2af150a2fb3eae7aa52e43e2b1920449.png)

---

<div class="post-metadata">

### Author: ![nathan1](https://avatars.discourse-cdn.com/v4/letter/n/8baadc/32.png) [@nathan1](https://discourse.nodered.org/u/nathan1)
#### Post date: [24 July 2024 14:06 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/7 "2024-07-24T14:06:50Z")

</div>

I moved it up to the first output and it seems to be giving an output now. However, the query is still empty.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/a/aad804585c457638e831b5f7a305a57d64b25750.png)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 July 2024 15:31 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/8 "2024-07-24T15:31:30Z")

</div>

> [@nathan1](#):
>
> the query is still empty.

Your function is not connected to the sqlite node.

---

<div class="post-metadata">

### Author: ![nathan1](https://avatars.discourse-cdn.com/v4/letter/n/8baadc/32.png) [@nathan1](https://discourse.nodered.org/u/nathan1)
#### Post date: [24 July 2024 15:52 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/9 "2024-07-24T15:52:41Z")

</div>

Thank you it works now. I have another question with read multiple. Is there a way to put the payload values in 1 array?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fd7cbcd0a4ac55d4f2d41f0da58dd18526a79df9.png)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 July 2024 16:38 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/10 "2024-07-24T16:38:12Z")

</div>

> [@nathan1](#):
>
> I have another question with read multiple. Is there a way to put the payload values in 1 array?

Is this a question about opcua or sqlite? If it is an opcua question it might be better to start a new thread. I have never used opcua.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [22 September 2024 16:39 UTC](https://discourse.nodered.org/t/opcua-client-sqlite-not-working/89683/11 "2024-09-22T16:39:00Z")

</div>

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