Double insert query inside a form

Hi all, i want to know with the plugin data manipulation (volkovlabs) how to make a double INSERT query, using the three variables in the form

i’m using Grafana v10.2.0
this is the form with the three variable

this is the complete script in the update request payload

this is the error

{“status”:400,“statusText”:“Bad Request”,“data”:{“results”:{“A”:{“error”:“db query error: Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘INSERT INTO sql.tab1 (var1, var4) VALUES (‘var1’, var4)’ at line 1”,“errorSource”:“”,“status”:500,“frames”:[{“schema”:{“refId”:“A”,“meta”:{“typeVersion”:[0,0],“executedQueryString”:“INSERT INTO sql.tab1 (var1, var2, var3) VALUES (‘var1’, ‘var2’, ‘89740496’);INSERT INTO sql.tab2 (var1, var4) VALUES (‘var1’, var4);”},“fields”:},“data”:{“values”:}}]}}},“config”:{“method”:“POST”,“url”:“api/ds/query”,“data”:{“queries”:[{“datasourceId”:12,“refId”:“A”,“rawSql”:“INSERT INTO sql.tab1 (var1, var2, var3) VALUES (‘var1’, ‘var2’, ‘89740496’);INSERT INTO sql.tab2 (var1, var4) VALUES (‘var1’, var4);”,“format”:“table”}]},“retry”:0,“headers”:{“X-Grafana-Org-Id”:1,“X-Grafana-Device-Id”:“dcbbdd185d1c15881f0c4aeab45ef11f”},“hideFromInspector”:false}}

with only one insert inside it, it runs successfully

Screenshot 2024-03-29 130208

THANKS for the help!

@nicolomenelle You need to combine two insert statements as one using with.

Check out the answer on the Stack Exchange:

@nicolomenelle You may look into using transactions or procedures to do the same.


Thank you so much @mikhailvolkov!!! Stored procedure on DB is the way :laughing:

const sql = CALL sql.tab_stored_proc ('${payload['var1']}', '${payload['var2']}', '${payload['var3']}', ${payload['var4']});


  • Data Source payload


return {

rawSql: sql,

format: ‘table’,


1 Like

@nicolomenelle Great! I hope everything else is clear with the Data Manipulation panel.