Hi ,
I have a query block on loop, that has to execute the below snowflake statement. execute immediate $$ declare rs RESULTSET; query varchar default 'SELECT * FROM '; final varchar; tableName STRING := {{ code2.data[0] }}; begin final := 'SELECT * FROM ' || tableName || ';'; rs:= (execute immediate :final); return table(rs); end; $$;
The table name is in code2.data. I would like to loop over the tableNames and execute the query.
But I'm recieving [null] as output.
The logs say "Invalid identifier '1'". Error at line 6 position 21.
I think you would need to disable prepared statements for the resource. There is some discussion on this in the below link (though for apps, I would guess it works for workflows too). Buyer beware in regards to opening up the danger of SQL injection in doing so.
One other thought would be a branch in the code that is used to direct toward one table or another. This would get exceedingly complicated and difficult to maintain if the number of possible tables is large (more than two, IMO ).