# Msg split, choose option and MySQL select

**URL:** <https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831>\
**Category:** General\
**Created:** [17 February 2020 07:44 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831 "2020-02-17T07:44:43Z")\
**Posts on this page:** 20\
**Page:** 2

<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:** [18 February 2020 09:49 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/21 "2020-02-18T09:49:19Z")

</div>

> [@Colin](#):
>
> Configure a debug node on the output of the sql node to Show Complete Message and also one on the input. Give them names so they are identifiable in the debug output. Run it and screenshot the result please. If you are using node-red-contrib-mssql-plus it should have the query in msg.query on the output.

Have you done that yet?

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 11:28 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/22 "2020-02-18T11:28:30Z")

</div>

yep Colin, got a slightly different error msg but that is:

18 Feb 12:27:59 - [error] [function:reformat] Function tried to send a message of type string

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [18 February 2020 11:36 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/23 "2020-02-18T11:36:17Z")

</div>

My guess is that you did something like this in your function

```auto
var x = "foo"
msg = x
return msg

```

which would set msg as a string, but it must be an object.

of course the fact you haven't shown what you are doing, this is only a guess.

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 11:40 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/24 "2020-02-18T11:40:49Z")

</div>

I am sending the following string to a mysql db:

"msg.topic : the query is not defined as a string"

18-2-2020 12:39:52[node: ffb21a77.04b158](http://localhost:1880/debug/view/view.html#)msg.payload : string[339]

"INSERT INTO FHIR2020.PISS (\_ID, \_VOORNAAM, \_ROEPNAAM, \_ACHTERNAAM, \_PARTNERNAAM, \_STRAATNAAM, \_HUISNUMMER, \_POSTCODE, \_WOONPLAATS, \_TELEFOONNUMMER, \_DIGID, \_KLINISCHNUMMER, \_POLIKLINISCHNUMMER, \_EXTRA, \_EXTRA2) VALUES (959993,'GRADUS','GER','BUURMAN','','KLAAS KATERSTRAAT','41','3122KL','SCHIEDAM','0629233911','09103781','1','1','', '');"

---

<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:** [18 February 2020 11:46 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/25 "2020-02-18T11:46:29Z")

</div>

> [@gbuurman](#):
>
> 3781','1','1','', '');"

Does that bit on the end look right to you?  
Every time you post the query it is different. If you stuck with one case and got it working instead of continually changing everything then it would be much easier.

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 12:00 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/26 "2020-02-18T12:00:28Z")

</div>

I complete rearrange the config. It is now steady. Originally it would receive a msg from a soapserver, reformat the message and execute the necessary sql statement. For the moment I am concentrating on splitting, checking and sending the message to mysql.

The original msg is:  
["SingleInsert","insert into fhir2020.piss (\_id, \_voornaam, \_roepnaam, \_achternaam, \_partnernaam, \_straatnaam, \_huisnummer, \_postcode, \_woonplaats, \_telefoonnummer, \_digid, \_klinischnummer, \_poliklinischnummer, \_extra, \_extra2) VALUES (959993,'Gradus','Ger','Buurman','','Klaas Katerstraat','41','3122KL','Schiedam','0629233911','09103781','1','1','', '');"] and is put in by a inject (the soapserver wille be next)

The flow looks like:

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

Sorry for the inconvenience Colin. I leave it as is.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [18 February 2020 12:05 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/27 "2020-02-18T12:05:42Z")

</div>

Please find one of your `mysql` nodes and click on it.  
In the sidebar - click the `info` tab  
read what it says

Now that you have done that, where should the sql query be in the msg object?

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 12:10 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/28 "2020-02-18T12:10:05Z")

</div>

Sorry but info tab. Must I double click or single click

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 12:11 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/29 "2020-02-18T12:11:32Z")

</div>

found it but no special information related to the msg

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 12:30 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/30 "2020-02-18T12:30:38Z")

</div>

this is the msg in the debug mode FROM NODE MYSQL;

msg : string[48]

"msg.topic : the query is not defined as a string"

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [18 February 2020 12:51 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/31 "2020-02-18T12:51:08Z")

</div>

Where does it say to place the query?

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 12:53 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/32 "2020-02-18T12:53:08Z")

</div>

at the mysql node itself.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [18 February 2020 13:32 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/33 "2020-02-18T13:32:45Z")

</div>

can you past a photo of where is says that? Because when I read the info tab it tells me where to put the query. Maybe we are looking at differrent nodes.

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 13:38 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/34 "2020-02-18T13:38:41Z")

</div>

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

See the text in the info box

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [18 February 2020 13:41 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/35 "2020-02-18T13:41:29Z")

</div>

Hoi Ger, ivm de informatie in die query, voor de veiligheid misschien de verdere info verbergen of onleesbaar maken voor de screenshot. Informatie over digid of poliklinische nummers lijken mij niet verantwoord op een publiek forum.  
M.v.g,  
Lena

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 13:43 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/36 "2020-02-18T13:43:45Z")

</div>

dat is allemaal geanonimiseerd maar dank voor de tip

Ger

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [18 February 2020 13:47 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/37 "2020-02-18T13:47:19Z")

</div>

I must not have been clear when I said go look at the info tab of the node in the sidebar. This is what I was refering to:  
 ![Screen Shot 2020-02-18 at 7.49.50 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/9/490da2a14cc937658198462fe71064beb5ac6da9.png)

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 13:57 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/38 "2020-02-18T13:57:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gbuurman](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gbuurman](https://discourse.nodered.org/u/gbuurman)\
**Post date:** [18 February 2020 13:58 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/39 "2020-02-18T13:58:19Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b8221c2e1587fab289d9bc0f19632a011a82567b.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:** [18 February 2020 14:01 UTC](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831/40 "2020-02-18T14:01:05Z")

</div>

So what does that say about where the query should be?

[Previous page](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831.md?page=1)

[Next page](https://discourse.nodered.org/t/msg-split-choose-option-and-mysql-select/21831.md?page=3)
