JavaScript Stored Procedures
Introduction
Section titled “Introduction”JavaScript Stored Procedures uses Snowflake JavaScript Procedures API. The API consists of JavaScript objects and the methods in those objects. You can declare JavaScript stored procedures, execute SQL via embedded JavaScript, call these using Snowflake’s supported methods.
The methods that we support thus far are:
snowflake.execute()snowflake.createStatement()statement.execute()resultSet.next()resultSet.getColumnValue()
Getting started
Section titled “Getting started”This guide is designed for users new to JavaScript Stored Procedures and assumes basic knowledge of JavaScript and Snowflake. Start LocalStack for Snowflake and execute Snowflake stored procedures in JavaScript.
Declare JavaScript procedures
Section titled “Declare JavaScript procedures”You can declare JavaScript procedures like this:
CREATE OR REPLACE PROCEDURE minimal_proc()RETURNS STRINGLANGUAGE JAVASCRIPTAS$$ var stmt = snowflake.createStatement({sqlText: "SELECT 'hello world'"}); var rs = stmt.execute(); ...$$;