# 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:** 3

<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/41 "2020-09-02T16:41:37Z")

</div>

```auto
if(msg.payload=="CR_SUCCESS"&& msg.id=='04222436')
{
let newMsg1 = {};
newMsg1.topic = `UPDATE NCS_DATABASE SET Status='DR1 OFF' WHERE Person_ID='${msg.id}'`;
return newMsg1;
}

```

---

<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:45 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/42 "2020-09-02T16:45:59Z")

</div>

You have shown the code but we also need to see the output of a debug node showing what is going into the function, and also what is coming out of the function node.  
Give the debug nodes names so we can see which is which and set them to Show Complete 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 17:38 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/43 "2020-09-02T17:38:59Z")

</div>

```auto
9/2/2020, 11:10:59 PMnode: DR1ON debug
UPDATE NCS_DATABASE SET Status='DR1 ON' WHERE Person_ID='04222436' : msg : Object
object
topic: "UPDATE NCS_DATABASE SET Status='DR1 ON' WHERE Person_ID='04222436'"
_msgid: "74b1d386.4ba3ec"

```

---

<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 17:39 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/44 "2020-09-02T17:39:20Z")

</div>

```auto
9/2/2020, 11:07:58 PMnode: DR1OFF debug
UPDATE NCS_DATABASE SET Status='DR1 OFF' WHERE Person_ID='04222436' : msg : Object
object
topic: "UPDATE NCS_DATABASE SET Status='DR1 OFF' WHERE Person_ID='04222436'"
_msgid: "dc47d4aa.bf953

```

---

<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 19:40 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/45 "2020-09-02T19:40:11Z")

</div>

Getting information from you is very difficult, it is no good just posting the result unless you tell us what is wrong with it.

---

<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:** [3 September 2020 05:15 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/46 "2020-09-03T05:15:17Z")

</div>

Sorry,Sir  
Problem is my DB is not updating result as per my requirements

---

<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:** [3 September 2020 05:17 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/47 "2020-09-03T05:17:27Z")

</div>

I want first DR ON should get updated when some person access the door with Person ID  
then i want DROFF after 4 sec to be updated in DB.  
problem is my flow and my idea is not working as per my requirement so help me by some idea.

---

<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:** [3 September 2020 06:57 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/48 "2020-09-03T06:57:05Z")

</div>

Once again your answer is confusing. Is it the update that is not working or the timing? If you want to delay one of the messages then feed the first message direct to the database node and feed the second through the delay node.

---

<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:** [3 September 2020 06:59 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/49 "2020-09-03T06:59:42Z")

</div>

update is like this  
steps  
1-\> entered the person id,CR\_SUCCESS i recieved,DRON geting updated and after 4 sec DROFF is updating.  
problem:  
Steps  
1-\>again if i am enterring person id ,CR\_SUCCESS i am getting but now that DRON is not updating in DB,it is showing the same DROFF ??????????

---

<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:** [3 September 2020 07:21 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/50 "2020-09-03T07:21:47Z")

</div>

Sir Should i attach my flow for your reference?/

---

<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:** [3 September 2020 08:08 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/51 "2020-09-03T08:08:19Z")

</div>

Do you mean it works the first time but not the second?  
Connect a debug node showing what is coming out of the database node (set to show complete message). Go through the sequence so that it fails and screenshot the resulting debug output.

---

<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:** [3 September 2020 09:12 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/52 "2020-09-03T09:12:22Z")

</div>

![2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/8/782af5563911e3b80b07d05ea2475d6f88469f57.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:** [3 September 2020 09:55 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/53 "2020-09-03T09:55:43Z")

</div>

You have not shown all the debug nor shown the start of the first one nor fully expanded the second one.  
Also how do you know that it has not worked?

---

<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:** [3 September 2020 10:29 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/54 "2020-09-03T10:29:29Z")

</div>

![5](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/425c088a85accb47f705e1b3c2724e4b1556d023.png) ![6](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/5071c5ec7e9b37a6c3db490c904d3e220238ac52.png)

check these attached screenshots

---

<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:** [3 September 2020 10:29 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/55 "2020-09-03T10:29:55Z")

</div>

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

---

<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:** [3 September 2020 10:41 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/56 "2020-09-03T10:41:10Z")

</div>

So you update a row in the database and change the column 'Status' to 'DR1 ON' then four seconds later change you update the same row in the database and change the column 'Status' to 'DR1 OFF'

What is the problem?

---

<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:** [3 September 2020 10:50 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/57 "2020-09-03T10:50:16Z")

</div>

> [@shipra](#):
>
> check these attached screenshots

It is no good just saying that. You must explain clearly what the debug is showing and what it should be showing. You still have not said exactly what is going wrong.

---

<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:** [3 September 2020 11:19 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/58 "2020-09-03T11:19:20Z")

</div>

Problem is after DROFF i want DRON again when i am enterring same person id if not then no change

---

<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:** [3 September 2020 11:20 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/59 "2020-09-03T11:20:55Z")

</div>

And what is your flow logic to do this?

---

<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:** [3 September 2020 11:21 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/60 "2020-09-03T11:21:59Z")

</div>

```auto
[
    {
        "id": "a0a22bbe.4dd42",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "b469431a.6aa488",
        "type": "mqtt in",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "topic": "FOB",
        "qos": "1",
        "datatype": "auto",
        "broker": "2b0fd3c9.2369b4",
        "x": 90,
        "y": 220,
        "wires": [
            [
                "950a518e.f68788"
            ]
        ]
    },
    {
        "id": "a5b28ca7.3f4ae8",
        "type": "mqtt out",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "topic": "MATCH",
        "qos": "1",
        "retain": "true",
        "broker": "2b0fd3c9.2369b4",
        "x": 1260,
        "y": 280,
        "wires": []
    },
    {
        "id": "4189be61.b54dd",
        "type": "sqlite",
        "z": "a0a22bbe.4dd42",
        "mydb": "ebf455b5.0e09e",
        "sqlquery": "msg.topic",
        "sql": "SELECT * FROM NCS WHERE Person_ID='{{payload}}';",
        "name": "SQLITE3",
        "x": 760,
        "y": 220,
        "wires": [
            [
                "81f4171d.a3c57"
            ]
        ]
    },
    {
        "id": "81f4171d.a3c57",
        "type": "switch",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "empty"
            },
            {
                "t": "nempty"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 850,
        "y": 300,
        "wires": [
            [
                "b6e09667.cfd1f8"
            ],
            [
                "47c73500.14fd6c"
            ]
        ]
    },
    {
        "id": "b6e09667.cfd1f8",
        "type": "change",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "CR_FAIL",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1040,
        "y": 220,
        "wires": [
            [
                "a5b28ca7.3f4ae8",
                "b4f536b1.835ee"
            ]
        ]
    },
    {
        "id": "47c73500.14fd6c",
        "type": "change",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "CR_SUCCESS",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1040,
        "y": 360,
        "wires": [
            [
                "a5b28ca7.3f4ae8",
                "b4c18fb9.b990e8",
                "743e1ca5.336ef4"
            ]
        ]
    },
    {
        "id": "4629413e.f8d6f",
        "type": "function",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "func": "let newMsg = {};\nnewMsg.topic = `SELECT Person_ID FROM NCS_DATABASE WHERE Person_ID='${msg.payload}'`;\nreturn newMsg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 520,
        "y": 220,
        "wires": [
            [
                "4189be61.b54dd"
            ]
        ]
    },
    {
        "id": "950a518e.f68788",
        "type": "function",
        "z": "a0a22bbe.4dd42",
        "name": "id no space ",
        "func": "msg.payload = msg.payload.replace(/\\s/g, '')\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 290,
        "y": 220,
        "wires": [
            [
                "4629413e.f8d6f",
                "7cc57b61.7cddbc"
            ]
        ]
    },
    {
        "id": "e1c813c6.492a18",
        "type": "function",
        "z": "a0a22bbe.4dd42",
        "name": "function2",
        "func": "let newMsg1 = {};\nnewMsg1.topic = `SELECT Fob_Tag_ID FROM NCS_DATABASE WHERE Fob_Tag_ID ='${msg.payload}'`;\nreturn newMsg1;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 520,
        "y": 280,
        "wires": [
            [
                "4189be61.b54dd"
            ]
        ]
    },
    {
        "id": "89c07b92.62f2",
        "type": "mqtt in",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "topic": "TRADE",
        "qos": "1",
        "datatype": "auto",
        "broker": "2b0fd3c9.2369b4",
        "x": 90,
        "y": 280,
        "wires": [
            [
                "42ce4ee7.c335d8"
            ]
        ]
    },
    {
        "id": "42ce4ee7.c335d8",
        "type": "function",
        "z": "a0a22bbe.4dd42",
        "name": "tagid no space ",
        "func": "msg.payload = msg.payload.replace(/\\s/g, '')\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 300,
        "y": 280,
        "wires": [
            [
                "e1c813c6.492a18",
                "ce2e3f7f.05cd6"
            ]
        ]
    },
    {
        "id": "8b7358f2.2eb348",
        "type": "mqtt in",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "topic": "FOB_and_TAG",
        "qos": "1",
        "datatype": "buffer",
        "broker": "2b0fd3c9.2369b4",
        "x": 120,
        "y": 360,
        "wires": [
            []
        ]
    },
    {
        "id": "b4c18fb9.b990e8",
        "type": "change",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "id",
                "pt": "msg",
                "to": "id",
                "tot": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1330,
        "y": 360,
        "wires": [
            [
                "cf6f5371.cdfa7",
                "c49d4ea7.7114e8"
            ]
        ]
    },
    {
        "id": "2cd6eb05.9d3e94",
        "type": "sqlite",
        "z": "a0a22bbe.4dd42",
        "mydb": "ebf455b5.0e09e",
        "sqlquery": "msg.topic",
        "sql": "UPDATE NCS_DATABASE\nSET Status='{{payload}}'\nWHERE Person_ID='{{id}}';",
        "name": "SQLITE3",
        "x": 1920,
        "y": 360,
        "wires": [
            [
                "b6956c2d.14843",
                "c0b6892.ddb8178"
            ]
        ]
    },
    {
        "id": "7cc57b61.7cddbc",
        "type": "change",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "id",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 420,
        "y": 160,
        "wires": [
            [
                "4629413e.f8d6f"
            ]
        ]
    },
    {
        "id": "ce2e3f7f.05cd6",
        "type": "change",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "id",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 420,
        "y": 340,
        "wires": [
            [
                "e1c813c6.492a18"
            ]
        ]
    },
    {
        "id": "1d52ba53.71e1de",
        "type": "function",
        "z": "a0a22bbe.4dd42",
        "name": "DR1OFF_Person ID",
        "func": "/*\n\n `UPDATE NCS_DATABASE SET Status='${msg.payload}' WHERE Person_ID='04222436'`;\n;*/\nlet newMsg1 = {};\n newMsg1.topic =setInterval(function(){ alert(\"DR1OFF\"); }, 4000);\nreturn newMsg1;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1220,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "56217bc.1faf604",
        "type": "debug",
        "z": "a0a22bbe.4dd42",
        "name": "NCS_debug1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1780,
        "y": 280,
        "wires": []
    },
    {
        "id": "c0ab02b9.8d1e1",
        "type": "debug",
        "z": "a0a22bbe.4dd42",
        "name": "NCS_debug11",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2300,
        "y": 620,
        "wires": []
    },
    {
        "id": "b6956c2d.14843",
        "type": "debug",
        "z": "a0a22bbe.4dd42",
        "name": "DR1OFF debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 2020,
        "y": 540,
        "wires": []
    },
    {
        "id": "b4f536b1.835ee",
        "type": "debug",
        "z": "a0a22bbe.4dd42",
        "name": " debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1470,
        "y": 220,
        "wires": []
    },
    {
        "id": "743e1ca5.336ef4",
        "type": "debug",
        "z": "a0a22bbe.4dd42",
        "name": " debug2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1500,
        "y": 260,
        "wires": []
    },
    {
        "id": "cf6f5371.cdfa7",
        "type": "function",
        "z": "a0a22bbe.4dd42",
        "name": "fun 1",
        "func": "\nlet newMsg1 = {};\nnewMsg1.topic = `UPDATE NCS_DATABASE SET Status='DR1 ON' WHERE Person_ID='${msg.id}'`;\nreturn newMsg1;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1570,
        "y": 360,
        "wires": [
            [
                "2cd6eb05.9d3e94",
                "56217bc.1faf604"
            ]
        ]
    },
    {
        "id": "e406ca6a.43f64",
        "type": "function",
        "z": "a0a22bbe.4dd42",
        "name": "FUN 1",
        "func": "if(msg.id==\"0422236\")\n{\nlet newMsg1 = {};\nnewMsg1.topic = `UPDATE NCS_DATABASE SET Status='DR1 OFF' WHERE Person_ID='${msg.id}'`;\nreturn newMsg1;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 2450,
        "y": 360,
        "wires": [
            [
                "16ccb566.94baeb",
                "7d03180.a2249e8"
            ]
        ]
    },
    {
        "id": "16ccb566.94baeb",
        "type": "debug",
        "z": "a0a22bbe.4dd42",
        "name": "DR1OFF debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 2400,
        "y": 260,
        "wires": []
    },
    {
        "id": "7d03180.a2249e8",
        "type": "sqlite",
        "z": "a0a22bbe.4dd42",
        "mydb": "ebf455b5.0e09e",
        "sqlquery": "msg.topic",
        "sql": "UPDATE NCS_DATABASE\nSET Status='{{payload}}'\nWHERE Person_ID='{{id}}';",
        "name": "SQLITE3",
        "x": 2640,
        "y": 460,
        "wires": [
            [
                "162f712c.af459f"
            ]
        ]
    },
    {
        "id": "162f712c.af459f",
        "type": "debug",
        "z": "a0a22bbe.4dd42",
        "name": "NCS_debug10",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2700,
        "y": 340,
        "wires": []
    },
    {
        "id": "c49d4ea7.7114e8",
        "type": "function",
        "z": "a0a22bbe.4dd42",
        "name": "fun 2",
        "func": "if(msg.id==\"04222437\")\n{\nlet newMsg1 = {};\nnewMsg1.topic = `UPDATE NCS_DATABASE SET Status='DR2 ON' WHERE Person_ID='${msg.id}'`;\nreturn newMsg1;\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1570,
        "y": 440,
        "wires": [
            [
                "2cd6eb05.9d3e94"
            ]
        ]
    },
    {
        "id": "1090af01.08e149",
        "type": "function",
        "z": "a0a22bbe.4dd42",
        "name": "FUN 2",
        "func": "if(msg.id==\"0422237\")\n{\nlet newMsg1 = {};\nnewMsg1.topic = `UPDATE NCS_DATABASE SET Status='DR2 OFF' WHERE Person_ID='${msg.id}'`;\nreturn newMsg1;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 2450,
        "y": 420,
        "wires": [
            [
                "7d03180.a2249e8",
                "c0ab02b9.8d1e1"
            ]
        ]
    },
    {
        "id": "c0b6892.ddb8178",
        "type": "delay",
        "z": "a0a22bbe.4dd42",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "x": 2080,
        "y": 280,
        "wires": [
            [
                "e406ca6a.43f64",
                "1090af01.08e149"
            ]
        ]
    },
    {
        "id": "2b0fd3c9.2369b4",
        "type": "mqtt-broker",
        "z": "",
        "name": "",
        "broker": "tcp://mqtt.eclipse.org",
        "port": "1883",
        "clientid": "NCS_Client_03",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": false,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "ebf455b5.0e09e",
        "type": "sqlitedb",
        "z": "",
        "db": "/home/shipra/Documents/NCS_Projects/IOT/NCS_API/NCS.db",
        "mode": "RWC"
    }
]

```

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

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