Same record is inserting twice

Hi All,
I am attaching the flow below ,where here using 2 moment nodes(node-red-contrib-moment) in the same flow, and I am facing the issue second moment node and insert function is printing twice in the debug console , so because of this, same two records are inserting into the database.
can you please help me .

here is the flow::

[{"id":"3e35e26b.9511be","type":"tab","label":"Order Sync to ERP","disabled":false,"info":""},{"id":"35df9403.12eb4c","type":"function","z":"3e35e26b.9511be","name":"Payload is not empty","func":" var SCBASICSYNC = global.get('appconfig').oracledbschema + . + global.get('appconfig').tableSCBASICSYNC;\n \n var orderbpmid = msg.payload.ORDERBPMID;\n node.log("orderbpmID=====>", +orderbpmid);\n \n var query = select * from + SCBASICSYNC + where ORDERBPMID = ' + orderbpmid + '\n msg.payload.query = query;\n \n return msg;","outputs":1,"noerr":0,"x":840,"y":120,"wires":[["63b73e4.56618c","b441396c.c303f8"]]},{"id":"3c89b607.f3e00a","type":"http in","z":"3e35e26b.9511be","name":"","url":"/vaighaibpm/api/v1/order","method":"post","upload":false,"swaggerDoc":"","x":190,"y":320,"wires":[["4422e947.e86728","f3d4af81.ebd4b","441e929.333d26c"]]},{"id":"db3d69a4.fb6098","type":"inject","z":"3e35e26b.9511be","name":"","topic":"","payload":"{"ORDERNUMBER":"ord-64","ORDERBPMID":"65cd-45f16-4f71-9ass-7b48a4ec0125","PARTYMASTID":"123456","PARTYMASTBMPID":"b2b04473-5f16-4f71-9a63-7b48a4ec01b2","ITEMMASTERID":"5500","ITEMMASTERBPMID":"k04473-5f16-4f71-9a63-7b48a4ec0166","UNIT":"hours","QTY":"1","ABCGRADE":"","RATE":"200","AMOUNT":"200","REMARKS":"","DUEDATE":"2019-02-26T16:55:00","ASTATUS":"Pending","USERCTRL":"abc","SALETYPE":"","SECTOR":"Fuel","SCBASICID":7656,"CONTRACTDOCID":"","CONTRACTBPMID":"","ORDSYNCSTATUS":"pending","ITEMID":"70042000119723","ITEMDESC":"Tablet is 7.00-inch display,resolution 1024 pixels by 600 pixels","PRIUNIT":"0909"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":240,"wires":[["4422e947.e86728","441e929.333d26c","50af73f8.8a1f9c"]]},{"id":"4422e947.e86728","type":"switch","z":"3e35e26b.9511be","name":"Checking SCBasicSync has same record","property":"payload","propertyType":"msg","rules":[{"t":"nempty"},{"t":"empty"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":160,"wires":[["35df9403.12eb4c"],["11a3871e.66ed39"]]},{"id":"11a3871e.66ed39","type":"function","z":"3e35e26b.9511be","name":"Payload is empty","func":"var SCBASICSYNC = global.get('appconfig').oracledbschema + . + global.get('appconfig').tableSCBASICSYNC;\nreturn null;","outputs":1,"noerr":0,"x":830,"y":200,"wires":[["638eb135.25a12"]]},{"id":"50b5d381.bb7cbc","type":"http response","z":"3e35e26b.9511be","name":"Failure response","statusCode":"400","headers":{},"x":550,"y":320,"wires":},{"id":"638eb135.25a12","type":"function","z":"3e35e26b.9511be","name":"Failure message","func":"msg.payload = {};\n\nmsg.payload.status="failed";\n\nmsg.payload.message = "Failed to Post data check input data"\n\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":260,"wires":[["50b5d381.bb7cbc"]]},{"id":"f3d4af81.ebd4b","type":"debug","z":"3e35e26b.9511be","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":290,"y":400,"wires":},{"id":"441e929.333d26c","type":"link out","z":"3e35e26b.9511be","name":"","links":["e0a9e450.95daa8"],"x":335,"y":100,"wires":},{"id":"63b73e4.56618c","type":"debug","z":"3e35e26b.9511be","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":950,"y":60,"wires":},{"id":"b441396c.c303f8","type":"oracle-db","z":"3e35e26b.9511be","name":"","x":1090,"y":220,"wires":[["1dff65.cfbbf09b","e1c26a14.db41a8"]]},{"id":"1dff65.cfbbf09b","type":"debug","z":"3e35e26b.9511be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1210,"y":140,"wires":},{"id":"bf47a416.7728b8","type":"function","z":"3e35e26b.9511be","name":"Insert Query","func":"msg.action = 'Insert';\n\nvar SCBASICSYNC = global.get('appconfig').oracledbschema + . + global.get('appconfig').tableSCBASICSYNC;\nnode.log("ramya")\nif (msg.payload) {\n node.log("msg.payload==>" + JSON.stringify(msg.payload))\n var lastupdated= msg.payload.dateoutput;\n //node.log("lastupdated===>", +lastupdated);\n var duedate = msg.payload.dueoutput;\n node.log("duedate===>", +duedate);\n\n var values = (' + msg.payload.ORDERBPMID + ',' + msg.payload.ORDERNUMBER + ', + msg.payload.PARTYMASTID + ,\n ' + msg.payload.PARTYMASTBMPID + ', + msg.payload.ITEMMASTERID + ,' + msg.payload.ITEMMASTERBPMID + ',\n ' + msg.payload.UNIT + ', + msg.payload.QTY + ,' + msg.payload.ABCGRADE + ', + msg.payload.RATE + ,\n + msg.payload.AMOUNT + ,' + msg.payload.REMARKS + ',TO_TIMESTAMP(' + duedate + ', 'YYYY-MM-DD HH24:MI:SS.FF'),\n ' + msg.payload.ASTATUS + ',' + msg.payload.USERCTRL + ',' + msg.payload.SALETYPE + ',' + msg.payload.SECTOR + ',\n + msg.payload.SCBASICID + ,' + msg.payload.CONTRACTDOCID + ',' + msg.payload.CONTRACTBPMID + ',\n ' + msg.payload.ORDSYNCSTATUS + ',' + msg.payload.ITEMID + ',' + msg.payload.ITEMDESC + ',\n + msg.payload.PRIUNIT + ,TO_TIMESTAMP(' + lastupdated + ', 'YYYY-DD-MM HH24:MI:SS.FF'),\n ' + msg.payload.PLANT + ', + msg.payload.BRANCHMASTID + , + msg.payload.ORDERSYNCID + )\n ;\n\n var query = INSERT INTO + SCBASICSYNC + (ORDERBPMID, ORDERNUMBER, PARTYMASTID, PARTYMASTBMPID, ITEMMASTERID,\n ITEMMASTERBPMID, UNIT, QTY, ABCGRADE, RATE, AMOUNT, REMARKS, DUEDATE, ASTATUS, USERCTRL, SALETYPE, SECTOR, SCBASICID,\n CONTRACTDOCID, CONTRACTBPMID,ORDSYNCSTATUS,ITEMID,ITEMDESC,PRIUNIT,LASTUPDATED,PLANT,BRANCHMASTID,ORDERSYNCID) VALUES + values;\n\n msg.payload.query = query;\n node.log("queryResult===>", msg.payload.query);\n \n\n}\n return msg;\n","outputs":1,"noerr":0,"x":470,"y":660,"wires":[["e6f658b3.71c228","4e2cee2f.ec4fe"]]},{"id":"e6f658b3.71c228","type":"debug","z":"3e35e26b.9511be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":670,"y":600,"wires":},{"id":"4e2cee2f.ec4fe","type":"oracle-db","z":"3e35e26b.9511be","name":"","x":810,"y":720,"wires":[["91a22547.f64da8","5abb8d6f.4f3b14"]]},{"id":"7c4d25a9.b3416c","type":"http response","z":"3e35e26b.9511be","name":"Response","statusCode":"200","headers":{},"x":1020,"y":860,"wires":},{"id":"91a22547.f64da8","type":"function","z":"3e35e26b.9511be","name":"Set response","func":"node.log("action========>" + msg.action);\nvar res = {};\n\nvar message ='';\n\nmessage = msg.action == 'Insert' ? 'Order Inserted succesfully':'Order Updated Succesfully'\n\nres.status = 'success';\n\nres.message = message\nnode.log("res.message==>" + res.message);\nmsg.payload = res;\n\nreturn msg;","outputs":1,"noerr":0,"x":1010,"y":720,"wires":[["7c4d25a9.b3416c","1d3c4ea3.d135a1"]]},{"id":"5abb8d6f.4f3b14","type":"debug","z":"3e35e26b.9511be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":910,"y":620,"wires":},{"id":"f6591c7a.8b4a7","type":"function","z":"3e35e26b.9511be","name":"Update Query","func":"node.log("ramya111111111")\nmsg.action = 'Update';\n\nvar SCBASICSYNC = global.get('appconfig').oracledbschema + . + global.get('appconfig').tableSCBASICSYNC;\n\nif (msg.payload) {\n node.log("raamya111111")\n var lastupdated= msg.payload.dateoutput;\n // node.log("lastupdated===>", +lastupdated);\n var duedate = msg.payload.dueoutput;\n \n msg.payload.query = '';\n\n var query = UPDATE + SCBASICSYNC + SET ORDERNUMBER =' + msg.payload.ORDERNUMBER + ', \n PARTYMASTID = ' + msg.payload.PARTYMASTID + ', PARTYMASTBMPID = ' + msg.payload.PARTYMASTBMPID + ', ITEMMASTERID = ' + msg.payload.ITEMMASTERID + ', \n ITEMMASTERBPMID = ' + msg.payload.ITEMMASTERBPMID + ', UNIT = ' + msg.payload.UNIT + ', QTY = + msg.payload.QTY + , \n ABCGRADE = ' + msg.payload.ABCGRADE + ',\n RATE = + msg.payload.RATE + , AMOUNT = + msg.payload.AMOUNT + , REMARKS = ' + msg.payload.REMARKS + ',\n DUEDATE = TO_TIMESTAMP(' + duedate + ', 'YYYY-MM-DD HH24:MI:SS.FF'), \n ASTATUS = ' + msg.payload.ASTATUS + ', USERCTRL = ' + msg.payload.USERCTRL + ', SALETYPE = ' + msg.payload.SALETYPE + ',\n SECTOR = ' + msg.payload.SECTOR + ', SCBASICID = ' + msg.payload.SCBASICID + ', CONTRACTDOCID = ' + msg.payload.CONTRACTDOCID + ',\n CONTRACTBPMID = ' + msg.payload.CONTRACTBPMID + ',ORDSYNCSTATUS = ' + msg.payload.ORDSYNCSTATUS + ',\n ITEMID = ' + msg.payload.ITEMID + ',ITEMDESC = ' + msg.payload.ITEMDESC + ',\n PRIUNIT = ' + msg.payload.PRIUNIT + ',LASTUPDATED = TO_TIMESTAMP(' + lastupdated + ', 'YYYY-DD-MM HH24:MI:SS.FF'),\n PLANT = ' + msg.payload.PLANT + ', BRANCHMASTID = ' + msg.payload.BRANCHMASTID + ', ORDERSYNCID = ' + msg.payload.ORDERSYNCID + '\n WHERE ORDERBPMID = ' + msg.payload.ORDERBPMID + ' ;\n \n\n msg.payload.query = query;\n\n return msg;\n\n}\n","outputs":1,"noerr":0,"x":460,"y":800,"wires":[["9189187b.463528","4e2cee2f.ec4fe"]]},{"id":"9189187b.463528","type":"debug","z":"3e35e26b.9511be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":630,"y":860,"wires":},{"id":"f66be923.8151e8","type":"switch","z":"3e35e26b.9511be","name":"Deciding Insert and Update","property":"responsedata.length","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"neq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":180,"y":740,"wires":[["bf47a416.7728b8"],["f6591c7a.8b4a7"]]},{"id":"520a80ae.3ad77","type":"debug","z":"3e35e26b.9511be","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1070,"y":380,"wires":},{"id":"50af73f8.8a1f9c","type":"debug","z":"3e35e26b.9511be","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":160,"y":60,"wires":},{"id":"b22bcad8.deacc8","type":"debug","z":"3e35e26b.9511be","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":750,"y":500,"wires":},{"id":"e1c26a14.db41a8","type":"moment","z":"3e35e26b.9511be","name":"","topic":"","input":"","inputType":"date","inTz":"Asia/Calcutta","adjAmount":0,"adjType":"hours","adjDir":"add","format":"YYYY-DD-MM HH:mm:ss","locale":"en_US","output":"payload.dateoutput","outputType":"msg","outTz":"Asia/Calcutta","x":820,"y":380,"wires":[["520a80ae.3ad77","6525df9c.73d06","6525df9c.73d06"]],"outputLabels":["YYYY DD MM HH:mm:ss"]},{"id":"6525df9c.73d06","type":"moment","z":"3e35e26b.9511be","name":"","topic":"","input":"payload.DUEDATE","inputType":"msg","inTz":"Asia/Calcutta","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm:ss","locale":"en_US","output":"payload.dueoutput","outputType":"msg","outTz":"Asia/Calcutta","x":480,"y":500,"wires":[["b22bcad8.deacc8","f66be923.8151e8"]]},{"id":"1d3c4ea3.d135a1","type":"debug","z":"3e35e26b.9511be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1220,"y":680,"wires":}]

Unfortunately your flow isn't currently importable.Please read the following post How to share code or flow json and then edit the above message.

I would add a debug node to each output of the “Deciding insert or update” to see what is showing up. You might want to add a debug node to the output of the first database node to see what you are retrieving.

[{"id":"6e9e4a88.0261c4","type":"tab","label":"Order Sync to ERP","disabled":false,"info":""},{"id":"78904ae2.44df94","type":"function","z":"6e9e4a88.0261c4","name":"Payload is not empty","func":" var SCBASICSYNC = global.get('appconfig').oracledbschema + `.` + global.get('appconfig').tableSCBASICSYNC;\n \n var orderbpmid = msg.payload.ORDERBPMID;\n var query = `select * from ` + SCBASICSYNC + ` where ORDERBPMID = '` + orderbpmid + `'`\n msg.payload.query = query;\n    \n return msg;","outputs":1,"noerr":0,"x":840,"y":120,"wires":[["3616ad47.4b78e2","a8cef2f0.294d4"]]},{"id":"7e9b30c2.38f23","type":"http in","z":"6e9e4a88.0261c4","name":"","url":"/vaighaibpm/api/v1/order","method":"post","upload":false,"swaggerDoc":"","x":190,"y":320,"wires":[["99d55aeb.c99618","7c671e31.74dd3","e9313e2a.46105"]]},{"id":"82142567.202868","type":"inject","z":"6e9e4a88.0261c4","name":"","topic":"","payload":"{\"ORDERNUMBER\":\"VA-2859\",\"ORDERBPMID\":\"482e3042-6731-47d6-b397-a17bc7fad91f\",\"PARTYMASTID\":\"40344000058123\",\"PARTYMASTBMPID\":\"a16d7df8-f29c-48fe-a075-c515c489b123\",\"ITEMMASTERID\":\"\",\"ITEMMASTERBPMID\":\"f872197f-2dd7-4f03-8449-df54e3518123\",\"UNIT\":\"Metric Ton\",\"QTY\":\"0.3\",\"ABCGRADE\":\"\",\"RATE\":\"00\",\"AMOUNT\":\"00\",\"REMARKS\":\"\",\"DUEDATE\":\"2019-11-02T16:55:00\",\"ASTATUS\":\"Pending\",\"USERCTRL\":\"abc\",\"SALETYPE\":\"abc\",\"SECTOR\":\"abc\",\"SCBASICID\":\"0\",\"CONTRACTDOCID\":\"\",\"CONTRACTBPMID\":\"\",\"ORDSYNCSTATUS\":\"pending\",\"ITEMID\":\"OIL (4-7)\",\"ITEMDESC\":\"OIL: FFA (4-7)\",\"PRIUNIT\":\"10002000000123\",\"LASTUPDATED\":\"\",\"PLANT\":\"Madurai\",\"BRANCHMASTID\":\"40139000007123\",\"ORDERSYNCID\":\"123\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":240,"wires":[["99d55aeb.c99618","e9313e2a.46105"]]},{"id":"99d55aeb.c99618","type":"switch","z":"6e9e4a88.0261c4","name":"Checking SCBasicSync has same record","property":"payload","propertyType":"msg","rules":[{"t":"nempty"},{"t":"empty"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":160,"wires":[["78904ae2.44df94"],["980e025.79a3f"]]},{"id":"980e025.79a3f","type":"function","z":"6e9e4a88.0261c4","name":"Payload is empty","func":"var SCBASICSYNC = global.get('appconfig').oracledbschema + `.` + global.get('appconfig').tableSCBASICSYNC;\nreturn null;","outputs":1,"noerr":0,"x":830,"y":200,"wires":[["8041fedb.bdef8"]]},{"id":"e45e70e8.32a5a","type":"http response","z":"6e9e4a88.0261c4","name":"Failure response","statusCode":"400","headers":{},"x":550,"y":320,"wires":[]},{"id":"8041fedb.bdef8","type":"function","z":"6e9e4a88.0261c4","name":"Failure message","func":"msg.payload = {};\n\nmsg.payload.status=\"failed\";\n\nmsg.payload.message = \"Failed to Post data check input data\"\n\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":260,"wires":[["e45e70e8.32a5a"]]},{"id":"7c671e31.74dd3","type":"debug","z":"6e9e4a88.0261c4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":290,"y":400,"wires":[]},{"id":"e9313e2a.46105","type":"link out","z":"6e9e4a88.0261c4","name":"","links":["56aac221.3df85c"],"x":335,"y":100,"wires":[]},{"id":"3616ad47.4b78e2","type":"debug","z":"6e9e4a88.0261c4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":950,"y":60,"wires":[]},{"id":"a8cef2f0.294d4","type":"oracle-db","z":"6e9e4a88.0261c4","name":"","x":1090,"y":220,"wires":[["c28afcb8.e34da","a576932c.476c6"]]},{"id":"c28afcb8.e34da","type":"debug","z":"6e9e4a88.0261c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1210,"y":140,"wires":[]},{"id":"9f5457ea.8184f8","type":"function","z":"6e9e4a88.0261c4","name":"Insert Query","func":"msg.action = 'Insert';\n\nvar SCBASICSYNC = global.get('appconfig').oracledbschema + `.` + global.get('appconfig').tableSCBASICSYNC;\n\nif (msg.payload) {\n    node.log(\"msg.payload==>\" + JSON.stringify(msg.payload))\n    var lastupdated=  msg.payload.dateoutput;\n  //  node.log(\"lastupdated===>\" + lastupdated);\n    var duedate = msg.payload.dueoutput;\n   // node.log(\"duedate===>\" + duedate);\n\n    //  var values = `('` + msg.payload.ORDERBPMID + `','` + msg.payload.ORDERNUMBER + `',` + msg.payload.PARTYMASTID + `,\n    //  '` + msg.payload.PARTYMASTBMPID + `',` + msg.payload.ITEMMASTERID + `,'` + msg.payload.ITEMMASTERBPMID + `',\n    //  '` + msg.payload.UNIT + `',` + msg.payload.QTY + `,'` + msg.payload.ABCGRADE + `',` + msg.payload.RATE + `,\n    //  ` + msg.payload.AMOUNT + `,'` + msg.payload.REMARKS + `',TO_TIMESTAMP('` + duedate + `', 'YYYY-MM-DD HH24:MI:SS.FF'),\n    //  '` + msg.payload.ASTATUS + `','` + msg.payload.USERCTRL + `','` + msg.payload.SALETYPE + `','` + msg.payload.SECTOR + `',\n    //  ` + msg.payload.SCBASICID + `,'` + msg.payload.CONTRACTDOCID + `','` + msg.payload.CONTRACTBPMID + `',\n    //  '` + msg.payload.ORDSYNCSTATUS + `','` + msg.payload.ITEMID + `','` + msg.payload.ITEMDESC + `',\n    //  ` + msg.payload.PRIUNIT + `,TO_TIMESTAMP('` + lastupdated + `', 'YYYY-DD-MM HH24:MI:SS.FF'),\n    //  '` + msg.payload.PLANT + `',` + msg.payload.BRANCHMASTID + `, ` + msg.payload.ORDERSYNCID + ` )\n    // `;\n     var values = `('` + msg.payload.ORDERBPMID + `','` + msg.payload.ORDERNUMBER + `','` + msg.payload.PARTYMASTID + `',\n     '` + msg.payload.PARTYMASTBMPID + `','` + msg.payload.ITEMMASTERID + `','` + msg.payload.ITEMMASTERBPMID + `',\n     '` + msg.payload.UNIT + `',` + msg.payload.QTY + `,'` + msg.payload.ABCGRADE + `',` + msg.payload.RATE + `,\n     ` + msg.payload.AMOUNT + `,'` + msg.payload.REMARKS + `',TO_TIMESTAMP('` + duedate + `', 'YYYY-MM-DD HH24:MI:SS.FF'),\n     '` + msg.payload.ASTATUS + `','` + msg.payload.USERCTRL + `','` + msg.payload.SALETYPE + `','` + msg.payload.SECTOR + `',\n     '` + msg.payload.SCBASICID + `','` + msg.payload.CONTRACTDOCID + `','` + msg.payload.CONTRACTBPMID + `',\n     '` + msg.payload.ORDSYNCSTATUS + `','` + msg.payload.ITEMID + `','` + msg.payload.ITEMDESC + `',\n     '` + msg.payload.PRIUNIT + `',TO_TIMESTAMP('` + lastupdated + `', 'YYYY-DD-MM HH24:MI:SS.FF'),\n     '` + msg.payload.PLANT + `','` + msg.payload.BRANCHMASTID + `', '` + msg.payload.ORDERSYNCID + `')`;\n\n    var query = `INSERT INTO ` + SCBASICSYNC + `(ORDERBPMID, ORDERNUMBER, PARTYMASTID, PARTYMASTBMPID, ITEMMASTERID,\n    ITEMMASTERBPMID, UNIT, QTY, ABCGRADE, RATE, AMOUNT, REMARKS, DUEDATE, ASTATUS, USERCTRL, SALETYPE, SECTOR, SCBASICID,\n    CONTRACTDOCID, CONTRACTBPMID,ORDSYNCSTATUS,ITEMID,ITEMDESC,PRIUNIT,LASTUPDATED,PLANT,BRANCHMASTID,ORDERSYNCID) VALUES ` + values;\n\n    msg.payload.query = query;\n   // node.log(\"queryResult===>\", msg.payload.query);\n  \n\n}\n  return msg;\n","outputs":1,"noerr":0,"x":490,"y":660,"wires":[["d03c291b.f51cd8","49ee800d.c3c47"]]},{"id":"d03c291b.f51cd8","type":"debug","z":"6e9e4a88.0261c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":670,"y":620,"wires":[]},{"id":"49ee800d.c3c47","type":"oracle-db","z":"6e9e4a88.0261c4","name":"","x":770,"y":700,"wires":[["25476c8c.c007f4","1a533e2d.840c42"]]},{"id":"295b7b61.e9e194","type":"http response","z":"6e9e4a88.0261c4","name":"Response","statusCode":"200","headers":{},"x":980,"y":800,"wires":[]},{"id":"25476c8c.c007f4","type":"function","z":"6e9e4a88.0261c4","name":"Set response","func":"\nvar res = {};\n\nvar message ='';\n\nmessage = msg.action == 'Insert' ? 'Order Inserted succesfully':'Order Updated Succesfully'\n\nres.status = 'success';\n\nres.message = message\n\nmsg.payload = res;\n\nreturn msg;","outputs":1,"noerr":0,"x":970,"y":700,"wires":[["295b7b61.e9e194","8856fc1f.c5807"]]},{"id":"1a533e2d.840c42","type":"debug","z":"6e9e4a88.0261c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":910,"y":640,"wires":[]},{"id":"a2ca86b.679dd78","type":"function","z":"6e9e4a88.0261c4","name":"Update Query","func":"\nmsg.action = 'Update';\n\nvar SCBASICSYNC = global.get('appconfig').oracledbschema + `.` + global.get('appconfig').tableSCBASICSYNC;\n\nif (msg.payload) {\n   \n    var lastupdated=  msg.payload.dateoutput;\n   // node.log(\"lastupdated===>\", +lastupdated);\n   var duedate = msg.payload.dueoutput;\n    \n    msg.payload.query = '';\n\n    var query = `UPDATE ` + SCBASICSYNC + ` SET ORDERNUMBER ='` + msg.payload.ORDERNUMBER + `', \n     PARTYMASTID = '` + msg.payload.PARTYMASTID + `', PARTYMASTBMPID = '` + msg.payload.PARTYMASTBMPID + `', ITEMMASTERID = '` + msg.payload.ITEMMASTERID + `', \n    ITEMMASTERBPMID = '` + msg.payload.ITEMMASTERBPMID + `', UNIT = '` + msg.payload.UNIT + `', QTY = ` + msg.payload.QTY + `, \n    ABCGRADE = '` + msg.payload.ABCGRADE + `',\n    RATE = ` + msg.payload.RATE + `, AMOUNT = ` + msg.payload.AMOUNT + `, REMARKS = '` + msg.payload.REMARKS + `',\n    DUEDATE = TO_TIMESTAMP('` + duedate + `', 'YYYY-MM-DD HH24:MI:SS.FF'), \n    ASTATUS = '` + msg.payload.ASTATUS + `', USERCTRL = '` + msg.payload.USERCTRL + `', SALETYPE = '` + msg.payload.SALETYPE + `',\n    SECTOR = '` + msg.payload.SECTOR + `', SCBASICID = '` + msg.payload.SCBASICID + `', CONTRACTDOCID = '` + msg.payload.CONTRACTDOCID + `',\n    CONTRACTBPMID = '` + msg.payload.CONTRACTBPMID + `',ORDSYNCSTATUS = '` + msg.payload.ORDSYNCSTATUS + `',\n    ITEMID = '` + msg.payload.ITEMID + `',ITEMDESC = '` + msg.payload.ITEMDESC + `',\n    PRIUNIT = '` + msg.payload.PRIUNIT + `',LASTUPDATED = TO_TIMESTAMP('` + lastupdated + `', 'YYYY-DD-MM HH24:MI:SS.FF'),\n    PLANT = '` + msg.payload.PLANT + `', BRANCHMASTID = '` + msg.payload.BRANCHMASTID + `', ORDERSYNCID = '` + msg.payload.ORDERSYNCID + `'\n    WHERE ORDERBPMID = '` + msg.payload.ORDERBPMID + `' `;\n    \n//     PARTYMASTID = ` + msg.payload.PARTYMASTID + `, PARTYMASTBMPID = '` + msg.payload.PARTYMASTBMPID + `', ITEMMASTERID = ` + msg.payload.ITEMMASTERID + `, \n//     ITEMMASTERBPMID = '` + msg.payload.ITEMMASTERBPMID + `', UNIT = '` + msg.payload.UNIT + `', QTY = ` + msg.payload.QTY + `, \n//     ABCGRADE = '` + msg.payload.ABCGRADE + `',\n//     RATE = ` + msg.payload.RATE + `, AMOUNT = ` + msg.payload.AMOUNT + `, REMARKS = '` + msg.payload.REMARKS + `',\n//     DUEDATE = TO_TIMESTAMP('` + duedate + `', 'YYYY-MM-DD HH24:MI:SS.FF'), \n//     ASTATUS = '` + msg.payload.ASTATUS + `', USERCTRL = '` + msg.payload.USERCTRL + `', SALETYPE = '` + msg.payload.SALETYPE + `',\n//     SECTOR = '` + msg.payload.SECTOR + `', SCBASICID = ` + msg.payload.SCBASICID + `, CONTRACTDOCID = '` + msg.payload.CONTRACTDOCID + `',\n//     CONTRACTBPMID = '` + msg.payload.CONTRACTBPMID + `',ORDSYNCSTATUS = '` + msg.payload.ORDSYNCSTATUS + `',\n//     ITEMID = '` + msg.payload.ITEMID + `',ITEMDESC = '` + msg.payload.ITEMDESC + `',\n//     PRIUNIT = ` + msg.payload.PRIUNIT + `,LASTUPDATED = TO_TIMESTAMP('` + lastupdated + `', 'YYYY-DD-MM HH24:MI:SS.FF'),\n//     PLANT = '` + msg.payload.PLANT + `', BRANCHMASTID = ` + msg.payload.BRANCHMASTID + `, ORDERSYNCID = ` + msg.payload.ORDERSYNCID + `\n//     WHERE ORDERBPMID = '` + msg.payload.ORDERBPMID + `' `;\n//   // TO_TIMESTAMP('` + duedate + `', 'YYYY-MM-DD HH24:MI:SS.FF')\n\n    msg.payload.query = query;\n\n    return msg;\n\n}\n","outputs":1,"noerr":0,"x":480,"y":760,"wires":[["9e39df1c.ee48e","49ee800d.c3c47"]]},{"id":"9e39df1c.ee48e","type":"debug","z":"6e9e4a88.0261c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":630,"y":840,"wires":[]},{"id":"a6d6b465.e03bb8","type":"switch","z":"6e9e4a88.0261c4","name":"Deciding Insert and Update","property":"responsedata.length","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"neq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":220,"y":720,"wires":[["9f5457ea.8184f8"],["a2ca86b.679dd78"]]},{"id":"2126e034.72074","type":"debug","z":"6e9e4a88.0261c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1130,"y":360,"wires":[]},{"id":"8856fc1f.c5807","type":"debug","z":"6e9e4a88.0261c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1161.6666666666665,"y":663.3333333333333,"wires":[]},{"id":"b8d60623.93c718","type":"debug","z":"6e9e4a88.0261c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":870,"y":520,"wires":[]},{"id":"a576932c.476c6","type":"moment","z":"6e9e4a88.0261c4","name":"","topic":"","input":"","inputType":"date","inTz":"Asia/Calcutta","adjAmount":0,"adjType":"hours","adjDir":"add","format":"YYYY-DD-MM HH:mm:ss","locale":"en_US","output":"payload.dateoutput","outputType":"msg","outTz":"Asia/Calcutta","x":900,"y":360,"wires":[["2126e034.72074","17c74a15.b7dc76","17c74a15.b7dc76"]],"outputLabels":["YYYY DD MM HH:mm:ss"]},{"id":"17c74a15.b7dc76","type":"moment","z":"6e9e4a88.0261c4","name":"","topic":"","input":"payload.DUEDATE","inputType":"msg","inTz":"Asia/Calcutta","adjAmount":0,"adjType":"hours","adjDir":"add","format":"YYYY-MM-DD HH:mm:ss","locale":"en_US","output":"payload.dueoutput","outputType":"msg","outTz":"Asia/Calcutta","x":520,"y":500,"wires":[["a6d6b465.e03bb8","b8d60623.93c718"]],"outputLabels":["YYYY DD MM HH:mm:ss"]}]

Did you follow @zenofmud's advise? Assuming that you have then you have not told us what the results were.

yep I tried that, but no use, for first db node,I am getting the response only once, but debug nodes are printing twice from second moment node on wards ,
I have attached the flow in the above comment, please have a look into it

So if I understand correctly you are getting one message out of the first moment node but that leads to two messages out of the second. If that is correct then have homed in on the problem. Show us the debug for those three messages.

image
In this image , first message for first moment node, second and third message for 2nd moment node

From first moment i am getting only one message, but from second moment, same message getting twice

Can you expand the payload in each case please.
Also stop node red then start it in a terminal and post the log that you get there please. It should contain the Welcome to node red message.

Also please name all your debug nodes. that will make it easier to see which debug output in the log goes with which debug node in the flow.