title: Accessing parameters in a SQL stored Procedure in Snowflake
body: <p>I am trying to create a stored procedure that uses an integer parameter and dateadd() to create a timestamp that's used to filter results in a where clause. I am getting &quot;Uncaught exception of type 'STATEMENT_ERROR' on line 3 at position 2 : SQL compilation error: error line 9 at position 53 invalid identifier 'X_DAYS_BACK'&quot; when I try to run the procedure below. If I move the return line above the create table line the procedure successfully runs and the return string includes the actual value of x_days_back (e.g. base.ITEM updated for last 3 days.).</p>
  <pre><code>CREATE OR REPLACE PROCEDURE BASE.ITEM_LOAD_test(X_DAYS_BACK INTEGER)
  returns string not null
  language SQL
  as
  $$
  BEGIN
    CREATE OR REPLACE TEMPORARY TABLE BASE.TEMP_DELTA_ITEM (
          ID STRING
        )
     AS
      SELECT
          SOURCE||KEY AS ID
        FROM BASE.SUPPLIER_CATALOG_ITEM
        WHERE
          CDP__ETL_UPDATE_TIMESTAMP &gt;= DATEADD(Day ,-1*X_DAYS_BACK, CURRENT_DATE);
      
      drop TABLE BASE.TEMP_DELTA_ITEM;
      
      RETURN 'base.ITEM updated for last ' ||  X_DAYS_BACK || ' days.' ;
  END;
  $$
  </code></pre>
  <p>How do I access a parameter of a SQL stored procedure within a function such as dateadd? I know it's a preview feature, so is this not currently implemented or?</p>