Professional Documents
Culture Documents
ExecuteMultipleSQLStmnts Snowflake
ExecuteMultipleSQLStmnts Snowflake
select 'drop table ' || "TABLE_NAME" || ';' from INFORMATION_SCHEMA.TABLES where "TA
1 of 5 19-02-2022, 14:00
Executing Multiple SQL Statements in a Stored Procedure https://snowflakecommunity.force.com/s/article/Executing-Multiple-SQL-Statements-in-a-Stor...
Row SQL_COMMAND
1 grant ownership on table CUSTOMER to role my_new_role copy grants;
2 grant ownership on table LINEITEM to role my_new_role copy grants;
3 grant ownership on table NATION to role my_new_role copy grants;
4 grant ownership on table ORDERS to role my_new_role copy grants;
2 of 5 19-02-2022, 14:00
Executing Multiple SQL Statements in a Stored Procedure https://snowflakecommunity.force.com/s/article/Executing-Multiple-SQL-Statements-in-a-Stor...
rs = stmt.execute();
var s = '';
while (rs.next()) {
cmd2_dict = {sqlText: rs.getColumnValue("SQL_COMMAND")};
stmtEx = snowflake.createStatement(cmd2_dict);
stmtEx.execute();
s += rs.getColumnValue(1) + "\n";
}
return s;
$$
;
3 of 5 19-02-2022, 14:00
Executing Multiple SQL Statements in a Stored Procedure https://snowflakecommunity.force.com/s/article/Executing-Multiple-SQL-Statements-in-a-Stor...
-- Confirm that the query_text variable has the correct SQL query
to generate our SQL commands (grants in this case) to run.
select $query_text;
-- Run the stored procedure. Note that to view its output better,
double click on the output to see it in multi-line format,
Call RunBatchSQL($query_text);
4 of 5 19-02-2022, 14:00
Executing Multiple SQL Statements in a Stored Procedure https://snowflakecommunity.force.com/s/article/Executing-Multiple-SQL-Statements-in-a-Stor...
Country *
5 of 5 19-02-2022, 14:00