I have a proc in dynamic sql throwing an error. I need to see the print statement of the sql the proc is running. The error message from snowflake is not very helpful.
Here is the stored proc I have
CREATE OR REPLACE PROCEDURE util.dbo.Restore_db_ver("source_db" varchar, "restore_db" varchar, "dest_db" varchar)
returns float
LANGUAGE JAVASCRIPT
AS
$$
var perm_cmd = "select cp_object,cp_object_name,cp_permission_type, cp_permission,cp_role from util.dbo.restore_perm where cp_database_name = '"+restore_db+"'"
var perm_cmd_stmt = snowflake.createStatement({sqlText: perm_cmd})
var perm_record = perm_cmd_stmt.execute()
while(perm_record.next())
{var perm_object = perm_record.getColumnValue(1)
var perm_object_name = perm_record.getColumnValue(2)
var perm_permission_type = perm_record.getColumnValue(3)
var perm_permission_name = perm_record.getColumnValue(4)
var perm_role_name = perm_record.getColumnValue(5)
var sql_cmd1 = "CREATE OR REPLACE DATABASE "+restore_db+" CLONE "+source_db+" AT (OFFSET => -1800)"
var statement1 = snowflake.createStatement( {sqlText: sql_cmd1} )
var result_set1 = statement1.execute()
var sql_cmd2 = perm_permission_type+" "+perm_permission_name+" ON "+perm_object+" "+perm_object_name+" TO ROLE "+perm_role_name
var statement2 = snowflake.createStatement( {sqlText: sql_cmd2} )
var result_set2 = statement2.execute()
}
$$
This is throwing an error JavaScript execution error: Uncaught ReferenceError: permission_name is not defined in RESTORE_DB_VER at ' var sql_cmd2 = perm_permission_type+" "+permission_name+" ON "+perm_object+" "+perm_object_name+" TO ROLE "+perm_role_name' position 44 stackstrace: RESTORE_DB_VER line: 17
Is there print command that I can use to output the sql?