title: Is it possible to SET a variable inside a stored procedure so that a view uses it?
body: <p>I have a view that depends on a session variable: </p>
  
  <pre><code>create or replace view test as 
  (
      select getvariable('MY_VAR')::int as col1
  ) ;
  </code></pre>
  
  <p>I can query that view like this: </p>
  
  <pre><code>set MY_VAR=5;
  select * from test; -- 5
  set MY_VAR=6;
  select * from test; -- 6
  </code></pre>
  
  <p>Now I want to do the same query from a stored procedure:</p>
  
  <pre><code>create or replace procedure myproc()
      returns VARCHAR
      language javascript
      as 
  $$
      var stmt = snowflake.createStatement({sqlText: "select * from test"});
      var rs = stmt.execute();
      rs.next(); // .next().getColumnValue(1);
  
      return rs.getColumnValue(1);
  $$
  ;
  
  call myproc() -- this work as long as MY_VAR is set outside before the call proc
  </code></pre>
  
  <p>The thing is that I want to set the the session variable from within the procedure and that is not allowed </p>
  
  <blockquote>
    <p>Stored procedure execution error: Unsupported statement type 'SET'. At Snowflake.execute</p>
  </blockquote>
  
  <p>Ultimately the goal is to have a Snowflake TASK that runs the stored procedure and I need to be able to set the variable somehow (the TASK doesn't allow to run set either, and neither does the stored procedure). </p>
  
  <p>Is there any workaround? </p>