Snowflake Scripting Developer Guide

Topics in this section explain how to write a stored procedure in SQL by using Snowflake Scripting. Snowflake Scripting is an extension to Snowflake SQL that adds support for procedural logic. You can use Snowflake Scripting to write stored procedures and procedural code outside of a stored procedure. This guide explains how to use Snowflake Scripting.

Using Snowflake Scripting in SnowSQL and the Classic Console

Get tips for coding in the Classic Console.

Understanding Blocks in Snowflake Scripting

Learn the basic structure of Snowflake Scripting code.

Working with Variables

Declare and use variables.

Returning a Value

Return values from stored procedures and an anonymous block.

Working with Branching Constructs

Control flow with IF and CASE statements.

Working with Loops

Control flow with FOR, WHILE, REPEAT, and LOOP.

Working with Cursors

Iterate through query results with a cursor.

Working with RESULTSETs

Iterate over the result set returned by a query.

Determining the Number of Rows Affected by DML Commands

Use global variables to determine the effect of data manipulation language (DML) commands.

Handling Exceptions

Handle errors by handling and raising exceptions.