Create SQL Insert Statement from a form input

Hi There,

Is it possible to use the form.data instead of having to define every single value and column on a SQL insert statement?

This is what is currently working.

I would like to do but haven't managed:

Update INTO comm_prop ( {{Object.keys(formNuevoItem.data)}} )
values (
{{Object.values(formNuevoItem.data)}}
)

Is this possible at all?

Thanks,
David

Use the GUI mode instead of SQL mode selector and yes this can be done.

2 Likes

@ScottR I cannot use the GUI as it fails when I try to do an insert. It could be due to the database being cockroachDB.

Any suggestions how to destructure an object so we can pass values into the SQL? I couldn't find anything on the

Here is a test example. Where I want to create the id from an array.

image

Here is what happens when I try using the GUI mode

I have worked it out. Instead of trying to run the INSERT statement for all rows at the same time what needs to happen is you need to call the INSERT (query) from a JS Query and pass each row to the INSERT which will then run the SQL script.

This is because there is some SQL Injection protection enabled in Retool and you don't want to disable it. This means you cannot add variables columns and values to the SQL.

Here is a good explanation on how to trigger the query and pass the row to the INSERT Query

2 Likes