Chapter 15. Snowflake Scripting Language

As mentioned in the Preface, SQL is a nonprocedural language, meaning that you define the desired results but not the steps needed to generate the results. This means that it’s up to Snowflake to determine the best (and hopefully fastest) method to retrieve the data, using the information it has gathered about your tables. Now it’s time to switch gears and discuss Snowflake’s procedural language, known as Snowflake Scripting language. This chapter will demonstrate the different language components, and the following two chapters will show how to use the Snowflake Scripting to build stored procedures and table functions.

A Little Background

If you’ve worked with databases other than Snowflake, you may already be familiar with using an embedded (executed from inside the database) procedural language. Some examples are Oracle’s PL/SQL or Microsoft’s Transact-SQL. If you aren’t familiar with these types of languages, just think of them as a language that includes the ability to execute select, delete, update, insert, and merge statements, along with constructs for variable definition, conditional logic (e.g., if-then-else), looping (e.g., for and while), and exception handling. You can build and execute scripts using Snowflake Scripting, and you can also compile and store your programs in the database (known as stored procedures).

There are multiple ways to interface with Snowflake. For example, if you write programs in Java, you can use Snowflake’s ...

Get Learning Snowflake SQL and Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.