3
votes

I am trying to execute remove file from snowflake internal stage via stored procedure. I'm getting this error:

Execution error in stored procedure RM_STAGE: Stored procedure execution error: Unsupported statement type 'UNKNOWN'. At Statement.execute, line 5 position 21

Is it possible to execute remove command via stored procedure?

Many Thanks, Sriga

1

1 Answers

2
votes

It is possible. The procedure needs to be a caller’s rights stored procedure. Below is an example of a SP that removes all files from a stage.

  create or replace procedure remove_stage_file()
  returns float
  language javascript
  EXECUTE AS CALLER
  as     
  $$  
        var my_sql_command = "remove @SPLITSTAGE" ;
        var statement1 = snowflake.createStatement( {sqlText: my_sql_command} );
        var result_set1 = statement1.execute();
        return 0;
  $$
  ;```