Hi I created a stored procedure in snowflake, and want to log the errors into a an log table when the query gets failed. in the table want to log the error message, query_id and query_text.here is code i tried:
create or replace procedure error_log_test()
returns varchar not null
language JAVASCRIPT
as
$$
try
{
var copy_into_cmd = `copy into my_table from @my_stage
file_format=(format_name= 'my_file_format')
on_error = skip_file;`;
var copy_into_stmt = snowflake.createStatement({sqlText: copy_into_cmd});
var result_set= copy_into_stmt.execute();
result_set.next();
}
catch(err)
{
var log_insert_into= snowflake.createStatement({sqlText:`insert into error_table
'err.code'
'err.message',
'${result_set.getColumnValue(7)}',
'${load_stmt.getSqlText()}';`});
log_insert_into.execute();
return err.message`enter code here`
$$
;
can nay suggest me the best way to do it, any guidance or suggestion are helpful.


