Workflow doesn't continue after the execution of Questdb node executing a query to truncate table

Hi,

I am working on a workflow which requires to enter some data to questdb. I want the workflow to remove all previous values from the table and add new ones each time the workflow executes. I have added two questdb nodes for this purpose. The first one executes the truncate table command which removes all data from the table ( keeps the row names - do not delete table.). The second one runs the query to insert the new values to the questdb. My workflow stops once it executes the first questdb node. How can I fix this?

I have added my workflow below. I tried to change the position of the first questdb node , but yields the same result only.

{
  "name": "MQTT-CLIENT-modified",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -160,
        340
      ]
    },
    {
      "parameters": {
        "path": "10f00915-b235-454b-a63f-a52bc8a3d8df",
        "responseMode": "lastNode",
        "responseData": "allEntries",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        60,
        340
      ],
      "webhookId": "10f00915-b235-454b-a63f-a52bc8a3d8df",
      "notesInFlow": true,
      "notes": "GET method to initiate the workflow"
    },
    {
      "parameters": {
        "authentication": "basicAuth",
        "url": "http://GSuPuBAdofKT2xLWLNZPwPSGedHrMlgq@mqtt-broker:8888/api/v1/session/show/--client_id\n",
        "allowUnauthorizedCerts": true,
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        390,
        340
      ],
      "notesInFlow": true,
      "credentials": {
        "httpBasicAuth": "Unnamed credential"
      },
      "notes": "HTTP Request to fetch the list of clients"
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"table\"][0][\"client_id\"]}}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        720,
        340
      ],
      "notesInFlow": true,
      "notes": "Checking whether clients are present or not"
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "Result",
              "value": "Error in obtaining list of all clients"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1010,
        170
      ],
      "notesInFlow": true,
      "notes": "Sets the error message when no client is connected"
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "client_id",
              "value": "={{$json[\"table\"]}}"
            }
          ],
          "boolean": [],
          "number": []
        },
        "options": {}
      },
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1010,
        510
      ],
      "notesInFlow": true,
      "notes": "Sets the client list"
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1320,
        170
      ]
    },
    {
      "parameters": {},
      "name": "NoOp1",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        2000,
        510
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO MQTTClient(client_id) VALUES ($1);\n",
        "additionalFields": {
          "queryParams": "client_id"
        }
      },
      "name": "QuestDB",
      "type": "n8n-nodes-base.questDb",
      "typeVersion": 1,
      "position": [
        1750,
        510
      ],
      "credentials": {
        "questDb": "QuestDB account 3"
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "client_id",
        "options": {}
      },
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        1320,
        510
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "TRUNCATE TABLE MQTTClient;",
        "additionalFields": {}
      },
      "name": "QuestDB1",
      "type": "n8n-nodes-base.questDb",
      "typeVersion": 1,
      "position": [
        1550,
        510
      ],
      "credentials": {
        "questDb": "QuestDB account 3"
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "Item Lists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists": {
      "main": [
        [
          {
            "node": "QuestDB1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "QuestDB": {
      "main": [
        [
          {
            "node": "NoOp1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "QuestDB1": {
      "main": [
        [
          {
            "node": "QuestDB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": 37
}```

Hi @Dhanya_V_Sagar, could you share your workflow using the option for preformatted text?
image

Or alternatively put three backticks (```) manually in the lines above and below your snippet? Otherwise no one would be able to copy and paste your workflow since it gets formatted for reading rather than as code. Many thanks!

I am sorry about that. I have the workflow here.

Hope this is alright. I have edited the previous one as well. Thank you for pointing this out.

No problem at all and thanks so much for sharing the codified workflow!

As for the actual question: Your QuestDB1 node passes on no items following the truncate statement. So your subsequent QuestDB node has no items to insert.

In order to make sure your workflow continues with the items from before QuestDB1 node (with the truncate statement), you might want to do something like this:

In this example I have set the Truncate node to always output an item (which would be empty), this prevents the workflow from stopping afterwards. I then use a Merge node in Pass-Through mode to get back the items from before my Truncate node.

This would first truncate my table and then insert multiple items.

Example Workflow
1 Like

This works !!! Thank you .

1 Like