title: How to call a procedure inside another procedure in snowflake
body: <p>Here is my stored procedure that retrieves all the column names of a table. I want to call this procedure inside another procedure.</p>
  <pre><code>CREATE OR REPLACE PROCEDURE get_columns(TABLE_NAME VARCHAR)
  RETURNS ARRAY
  LANGUAGE JAVASCRIPT
  AS
  $$
  var stmt = snowflake.createStatement({
      sqlText: &quot;SELECT * FROM &quot; + TABLE_NAME + &quot; LIMIT 1;&quot;,    
  });
  stmt.execute();
  
  var cols=[];
  for (i = 1; i &lt;= stmt.getColumnCount(); i++) {
    cols.push(stmt.getColumnName(i));
  }
  return cols
  $$;
  </code></pre>
  <p>Below is the main procedure that calls the above procedure and return an array of column names. But I don't understand where I'm going wrong.</p>
  <pre><code>CREATE OR REPLACE PROCEDURE get_data()   //procedure call the above procedure
      RETURNS ARRAY
      LANGUAGE JAVASCRIPT
      AS
      $$
      var arr = [];
      var r = snowflake.createStatement({sqlText: &quot;call get_columns('Table_Name')&quot;});
      arr = r.execute();  //r.execute() returns an array
      return arr; //getting an error
      $$
  </code></pre>