'{{}}' cannot be used when using the DO-END statement in SQL

I am trying to store API json value in SQL db.

DO $$
BEGIN
	FOR i in 1..10 LOOP
  	INSERT INTO tableName (columnName) VALUES ('{ "A": "1", "B": {"C": "2","qty": 3}}');
	END LOOP;
END; $$

this syntax works but,

DO $$
BEGIN
	FOR i in 1..{{text1.value}} LOOP
  	INSERT INTO tableName (columnName) VALUES ({{query.data[i]}});
	END LOOP;
END; $$

this syntax does not work with the following error

* error:true
* message:"bind message supplies 2 parameters, but prepared statement "" requires 0"
* source:"resource"

i think {{text1.value}}, {{query.data[i]}} is the problem. is there any other way to use it?

@finn you might need to disable prepared statements in your DB settings in Retool

What is the solution that worked here? I am getting the error even though prepared statement checkbox is unchecked for redshift in my retool instance. And it is redshift table as I mentioned

Hello @rgupta,

In the case @finn, his issue was resolved by disabling prepared statements.

Please could you share the snippet of your failing query?

Here is a cheatsheet that shows how to use the WHERE syntax in redshift