# Global variable call in postgrestor node - where condition

**URL:** <https://discourse.nodered.org/t/global-variable-call-in-postgrestor-node-where-condition/61709>\
**Category:** Developing Nodes\
**Tags:** database, function-node\
**Created:** [24 April 2022 10:05 UTC](https://discourse.nodered.org/t/global-variable-call-in-postgrestor-node-where-condition/61709 "2022-04-24T10:05:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![learnobyte](https://avatars.discourse-cdn.com/v4/letter/l/d6d6ee/32.png) [@learnobyte](https://discourse.nodered.org/u/learnobyte)\
**Post date:** [24 April 2022 10:05 UTC](https://discourse.nodered.org/t/global-variable-call-in-postgrestor-node-where-condition/61709/1 "2022-04-24T10:05:40Z")

</div>

Hi, how to use/declare global variable in select query where condition? i tried below this flow,  
select query returns rowcount value as zero, would like to know how to declare global variable in sql query.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/47a508f1a4a8e130b01852370900b53f581e01df.png)

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 April 2022 10:19 UTC](https://discourse.nodered.org/t/global-variable-call-in-postgrestor-node-where-condition/61709/2 "2022-04-24T10:19:52Z")

</div>

To use currentuser variable in the next node, you have to add it to the msg  
e.g....

```auto
msg.currentuser = global.get("currentuser")
return msg;

```

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

---

<div class="post-metadata">

**Author:** ![learnobyte](https://avatars.discourse-cdn.com/v4/letter/l/d6d6ee/32.png) [@learnobyte](https://discourse.nodered.org/u/learnobyte)\
**Post date:** [24 April 2022 10:34 UTC](https://discourse.nodered.org/t/global-variable-call-in-postgrestor-node-where-condition/61709/3 "2022-04-24T10:34:34Z")

</div>

Thanks @Steve-Mcl i got it

---

<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:** [8 May 2022 10:35 UTC](https://discourse.nodered.org/t/global-variable-call-in-postgrestor-node-where-condition/61709/4 "2022-05-08T10:35:11Z")

</div>

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