# Update query in sqlite3 with fob id coming from gateway code

**URL:** <https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292>\
**Category:** General\
**Created:** [1 September 2020 10:08 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292 "2020-09-01T10:08:49Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [1 September 2020 12:52 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/21 "2020-09-01T12:52:32Z")

</div>

Interesting .. the plot thickens ..

So the field seems to be there ..  
Shipra .. run those commands Steve send you and run the select \* query to see the result with the headers on

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [1 September 2020 12:53 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/22 "2020-09-01T12:53:53Z")

</div>

> [@shipra](#):
>
> " " this quotes was missing

What ? where ? 😉

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [1 September 2020 12:54 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/23 "2020-09-01T12:54:56Z")

</div>

Sir headers i have on but see o=how my output is looking

```auto
SrNo Date_and_Time Event_Type Event_Description Person_ID Person_Name_Description Fob_Tag_ID Door_ID Door_Description Status    
---------- ------------- ---------- ----------------- ---------- ----------------------- ---------- ---------- ---------------- ----------
1 04222436 2813 "DR1_ON"  
2 04222437 2814                                                
sqlite> 

```

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [1 September 2020 12:59 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/24 "2020-09-01T12:59:48Z")

</div>

Did you change something in node red to get it working ? and where?

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [1 September 2020 13:00 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/25 "2020-09-01T13:00:47Z")

</div>

> [@shipra](#):
>
> ```auto
> 
> ```

i have added " " this in switch payload

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [1 September 2020 13:03 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/26 "2020-09-01T13:03:52Z")

</div>

well .. im glad its working

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [1 September 2020 13:26 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/27 "2020-09-01T13:26:27Z")

</div>

Thank you sir for helping

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [2 September 2020 05:40 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/28 "2020-09-02T05:40:18Z")

</div>

Hello Sir,good Morning One query i have . I have to update my database directly when i get CR\_SUCCESS not by that Door Switch .how can i do this.

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [2 September 2020 07:26 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/29 "2020-09-02T07:26:13Z")

</div>

we don't know the latest updates you made in your flow to answer that .. but i think you have to move the _ **update db logic** _, after your switch node that produces that CR\_SUCCESS message.

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [2 September 2020 11:19 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/30 "2020-09-02T11:19:37Z")

</div>

Sir, when i am getting CR\_SUCCESS automatically DR gets ON. But I want that after 5 secs DR OFF should be updated in DB.  
And again if someone scan with Person ID again DR ON gets updated on DB?

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [2 September 2020 12:21 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/31 "2020-09-02T12:21:21Z")

</div>

> [@shipra](#):
>
> But I want that after 5 secs

It seems that you need to introduce a **delay** in your messages.  
There is a video on the Node-red youtube channel for this.

**[Node-RED Essentials Playlist](https://www.youtube.com/watch?v=CYDBnP4FN-s&list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6&index=17)**

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [2 September 2020 12:39 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/32 "2020-09-02T12:39:23Z")

</div>

Sir ,I have done and tried some way with some delays but not getting the required output.  
Please can you check ones and give any modifications

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

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [2 September 2020 13:03 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/33 "2020-09-02T13:03:15Z")

</div>

Im sure if you study all the tutorials in that playlist you will find the solution the same way you found the solution before when you were trying to do the sql UPDATE.  
**You** found the solution for that. not me 😉

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [2 September 2020 14:17 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/34 "2020-09-02T14:17:27Z")

</div>

Sir ,you helped me in that not me.  
Sir i have posted one screenshot please check where i am wrong.

---

<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:** [2 September 2020 14:48 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/35 "2020-09-02T14:48:46Z")

</div>

Which node in the flow is not doing what you expect? What is it doing and what do you expect it to do?

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [2 September 2020 15:58 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/36 "2020-09-02T15:58:04Z")

</div>

DR1 OFF\_Person ID is not working .I want after getting CR\_SUCCESS DR1 ON should get updated in DB and the after 4s delay DR1OFF\_Person ID should update DR1OFF in the same column of DB.

---

<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:** [2 September 2020 16:05 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/37 "2020-09-02T16:05:22Z")

</div>

Do you mean the delay is not working or the function node is not working? If you have the delay node set to Delay Each Message then each message will get sent four seconds after that message was received, so if you get two messages one after the other going in then they will both appear together four seconds later on the output. I wonder whether what you want is to force a delay between messages, in which case perhaps you want it in Rate mode, one message every 4 seconds.

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [2 September 2020 16:17 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/38 "2020-09-02T16:17:12Z")

</div>

Hello Sir, I will elaborate my aim ones .Actually I have a DB where Status is a column in which any updation is send by node red .  
In gateway code I am taking Person\_ID(Similar to rfid) if that id exist in DB CR\_SUCCESS i am receiving.  
Now after CR\_SUCCESS automatically DR1 should get open and DR1ON should get updated on Status column in DB.  
My Query is after updating DR1ON in DB after 4 or 5 sec DR gets closed and DR1OFF should get updated again in DB.

---

<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:** [2 September 2020 16:28 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/39 "2020-09-02T16:28:17Z")

</div>

So which node is not doing what you expect? If it is the function node then show us what is going into it, what is coming out and what you want instead. Also post the function node text, using the `</>` button and paste it in.  
If it is the delay node then screenshot a debug showing what is going in and another showing what is going out so we can see the timings, and tell us what is wrong with the timings.

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [2 September 2020 16:41 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/40 "2020-09-02T16:41:17Z")

</div>

Sir may be I am wrong ,please check and suggest

```auto
let newMsg1 = {};
newMsg1.topic = `UPDATE NCS_DATABASE SET Status='DR1 ON' WHERE Person_ID='04222436'`;
return newMsg1;

```

[Previous page](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292.md?page=1)

[Next page](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292.md?page=3)
