# How to use msg.payload or global variables in postgrestor node?

**URL:** <https://discourse.nodered.org/t/how-to-use-msg-payload-or-global-variables-in-postgrestor-node/28712>\
**Category:** General\
**Created:** [22 June 2020 07:04 UTC](https://discourse.nodered.org/t/how-to-use-msg-payload-or-global-variables-in-postgrestor-node/28712 "2020-06-22T07:04:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiao1201](https://avatars.discourse-cdn.com/v4/letter/x/e68b1a/32.png) [@xiao1201](https://discourse.nodered.org/u/xiao1201)\
**Post date:** [22 June 2020 07:04 UTC](https://discourse.nodered.org/t/how-to-use-msg-payload-or-global-variables-in-postgrestor-node/28712/1 "2020-06-22T07:04:01Z")

</div>

Hi there, so I'm using postgrestor node in NR and am able to do some sql operations by the postgrestor node just fine. My question is: how to use msg.payload or NR global varaible in the postgrestor node because the postgrestor node only recogonize sql statements not javascript statements. Thank you.

---

<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:** [22 June 2020 09:48 UTC](https://discourse.nodered.org/t/how-to-use-msg-payload-or-global-variables-in-postgrestor-node/28712/2 "2020-06-22T09:48:10Z")

</div>

what is the exact name of the node you are using? If you go to the flows tab and enter 'postgrestor' it returns 3 nodes....

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 June 2020 10:12 UTC](https://discourse.nodered.org/t/how-to-use-msg-payload-or-global-variables-in-postgrestor-node/28712/3 "2020-06-22T10:12:59Z")

</div>

In general most people use either a change node, or a template node, or a function node in front of a database node in order to construct and format up the query correctly.

---

<div class="post-metadata">

**Author:** ![xiao1201](https://avatars.discourse-cdn.com/v4/letter/x/e68b1a/32.png) [@xiao1201](https://discourse.nodered.org/u/xiao1201)\
**Post date:** [23 June 2020 00:51 UTC](https://discourse.nodered.org/t/how-to-use-msg-payload-or-global-variables-in-postgrestor-node/28712/4 "2020-06-23T00:51:30Z")

</div>

hi the node name is postgrestor,  
Yet another Node-RED node to query PostgreSQL

---

<div class="post-metadata">

**Author:** ![xiao1201](https://avatars.discourse-cdn.com/v4/letter/x/e68b1a/32.png) [@xiao1201](https://discourse.nodered.org/u/xiao1201)\
**Post date:** [23 June 2020 00:52 UTC](https://discourse.nodered.org/t/how-to-use-msg-payload-or-global-variables-in-postgrestor-node/28712/5 "2020-06-23T00:52:34Z")

</div>

yeah i understand but i dont know how to somehow pass the NR objects to SQL variables as the postgrestor node only has one SQL input field...

---

<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 August 2020 00:52 UTC](https://discourse.nodered.org/t/how-to-use-msg-payload-or-global-variables-in-postgrestor-node/28712/6 "2020-08-22T00:52:38Z")

</div>

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