I have tried below code to create tables that listed in tables array, but i get error:
JavaScript compilation error: Uncaught SyntaxError: Unexpected end of input in CREATE_TABLES_SP at '
CREATE OR REPLACE PROCEDURE create_tables_sp() //Procedure to create tables
RETURNS string
LANGUAGE JAVASCRIPT
AS
$$
var tables = ['table_a', 'table_b', 'table_c'];
for (var table of tables){
try {
snowflake.execute (
{sqlText: "create or replace table PROD_DB.schema1.${table} (ename varchar);"}
);
return "Succeeded."; // Return a success/error indicator.
}
catch (err) {
return "Failed: " + err; // Return a success/error indicator.
}
$$;
Does anyone know what i'm missing?