# Switch on RowDataPacket contents

**URL:** <https://discourse.nodered.org/t/switch-on-rowdatapacket-contents/42663>\
**Category:** General\
**Created:** [15 March 2021 11:10 UTC](https://discourse.nodered.org/t/switch-on-rowdatapacket-contents/42663 "2021-03-15T11:10:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaguar](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jaguar](https://discourse.nodered.org/u/jaguar)\
**Post date:** [15 March 2021 11:10 UTC](https://discourse.nodered.org/t/switch-on-rowdatapacket-contents/42663/1 "2021-03-15T11:10:44Z")

</div>

Struggling to understand how to use a switch node to switch based on the content of a RowDataPacket returned from a SQL Select in a Function Node.

The output from the SQL Select is always a single name / value object

[RowDataPacket { access: 1 }]

and access will either be 0 or 1.

The logic is simple, activate output 1 if access = 1

I have ready many posts and some seem to suggest that I need a split node or another function node to split the array before passing the value to the switch node Is this true?

Regards  
Ralph

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 March 2021 11:49 UTC](https://discourse.nodered.org/t/switch-on-rowdatapacket-contents/42663/2 "2021-03-15T11:49:47Z")

</div>

Hi @jaguar

My guess is you can use `msg.payload[0].access` in the switch node to check that value.

If that doesn't work, can you pass that message to a Debug node and show us how it gets displayed there?

---

<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:** [15 March 2021 11:53 UTC](https://discourse.nodered.org/t/switch-on-rowdatapacket-contents/42663/3 "2021-03-15T11:53:04Z")

</div>

The was just a fix applied to node-red-node-mysql (v0.1.2) that eliminates that issue so that it will always return an array. So `RowDataPacket`will not be in the results of a select anymore.

---

<div class="post-metadata">

**Author:** ![jaguar](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jaguar](https://discourse.nodered.org/u/jaguar)\
**Post date:** [15 March 2021 11:56 UTC](https://discourse.nodered.org/t/switch-on-rowdatapacket-contents/42663/4 "2021-03-15T11:56:50Z")

</div>

Thanks Knolleary, you are a life-saver.

I am dismayed after many hours struggling with this.

---

<div class="post-metadata">

**Author:** ![jaguar](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jaguar](https://discourse.nodered.org/u/jaguar)\
**Post date:** [15 March 2021 12:01 UTC](https://discourse.nodered.org/t/switch-on-rowdatapacket-contents/42663/5 "2021-03-15T12:01:44Z")

</div>

Thanks zenofmud, that's good to know. Someday I may find time to update things instead of struggling all the time.

---

<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:** [29 March 2021 12:02 UTC](https://discourse.nodered.org/t/switch-on-rowdatapacket-contents/42663/6 "2021-03-29T12:02:44Z")

</div>

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