Snowflake Scripting 101: Error Handling

In my other articles, we have talked about how to use basic blocks in Snowflake scripting, how to use Snowflake cursors and Snowflake scripting control structures. In this article, we will check handling error in Snowflake scripting with some relevant examples. Page Contents Introduction Understanding Errors in Snowflake Handling an Exception in Snowflake Scripting Built-in Variables in Snowflake Error Handling Declaring an User-Defined Exception in Snowflake Raising a Declared Exception in Snowflake Basic Snowflake Error Handling Examples Snowflake Anonymous Block with Error Handling Examples Snowflake Stored Procedure with Error Handling…

Comments Off on Snowflake Scripting 101: Error Handling

Snowflake Scripting 101: Control Structures

In my other articles, we have talked about how to use basic blocks in Snowflake scripting , how to use Snowflake cursors and Snowflake scripting error handling. In this article, we will check Snowflake scripting control structures such as IF, WHILE, FOR, REPEAT and LOOP with some relevant examples. Page Contents Introduction Fundamental Control Structures in Snowflake Snowflake Conditional control structures and Examples IF Statement Example: Snowflake Script Stored Procedure with IF-ELSE Block Snowflake Iterative control structures and Examples WHILE loops in Snowflake FOR loops in Snowflake REPEAT in Snowflake…

Comments Off on Snowflake Scripting 101: Control Structures

Snowflake Scripting 101: Snowflake Cursors

In another article, we talked about using blocks in Snowflake scripting and Snowflake scripting error handling.. Now, let's learn about something called the Snowflake cursors. We'll see how to use it in stored procedures and anonymous blocks. Page Content Introduction to Snowflake Cursors Understanding Cursor in Snowflake Cursor Syntax and how to use it? Declaring Cursors Opening Cursors Fetching Data from Cursors Closing Cursors Advanced Cursor Techniques Bulk fetching Avoiding large result sets Snowflake Cursor Examples Snowflake Anonymous Block with Cursor Snowflake Stored Procedure with Cursor Returning a Table for…

Comments Off on Snowflake Scripting 101: Snowflake Cursors

Snowflake Scripting 101: Blocks in Snowflake Scripting

Harness the full potential of Snowflake scripting to streamline data operations and automate complex business logics. Dive into this practical guide to discover how scripting blocks transform your Snowflake scripting experience, enabling: Precise control over data flows Optimized conditional logic Efficient looping structures Custom error handling And more! Page Content Understanding Blocks Structure of Block in a Snowflake Scripting Types of Blocks in Snowflake Scripting Common Block Use Cases Advanced Block Techniques Conclusion Understanding Blocks in Snowflake Scripting In Snowflake Scripting, blocks serve as essential building blocks for organizing and…

Comments Off on Snowflake Scripting 101: Blocks in Snowflake Scripting

How to Create Synonyms in Snowflake – Alternate Method

Relational databases utilize synonyms to conveniently assign names to lengthy tables, view names, or other objects like sequences, procedures, functions, and materialized views. Netezza and Oracle databases offer support for creating and managing synonyms. Synonyms serve as an alternative means of referencing tables or views within the current or other databases. However, Snowflake database presently lacks support for creating synonyms. In this article, we will explore an alternative method that resembles create synonyms in Snowflake. Page Content Introduction Understanding Synonyms in Databases Does Snowflake support Create Synonyms? Alternate Method for…

Comments Off on How to Create Synonyms in Snowflake – Alternate Method

How to Get Rows Affected by Last Snowflake SQL Query?

Databases such as Teradata (BTEQ), SQL Server, etc., allows you to get rows affected by the last DML statement using system variables. For example, ACTIVITY_COUNT in Teradata BTEQ. The row count of the last SQL query allows you to identify if there was any activity on table. Snowflake scripting provides system variables that hold the information of rows or records affected by an INSERT, UPDATE or DELETE queries in the current session. In this article, we will check how to get rows affected by last Snowflake SQL Query. How to Get Rows Affected…

Comments Off on How to Get Rows Affected by Last Snowflake SQL Query?

Dynamic SQL Queries in Snowflake Scripting

Dynamic SQL is one of the important features that many databases support. Dynamic SQL allows you to write SQL queries during runtime. With the help of dynamic SQL, you can build your SQL query on the fly and execute them. In the data warehouse, there may be a situation where you want to generate dynamic SQL queries based on your requirement. In this article, we will check how to use dynamic SQL queries in Snowflake scripting. Dynamic SQL Queries in Snowflake Scripting Dynamic SQL Queries in Snowflake Snowflake supports writing…

Comments Off on Dynamic SQL Queries in Snowflake Scripting

Working with Snowflake Scripting Stored Procedures

Writing stored procedure is one of the import method to encapsulate your business logic using procedural language. Snowflake does support writing a stored procedure using JavaScript and recently they started supporting SQL scripting much similar to Oracle PLSQL. In this article, we will check how to write Snowflake scripting stored procedures. We will also look into some examples. Snowflake Scripting Stored Procedures In general, Stored procedure combines the complex SQL business logic with procedural statements such as IF-ESLE, LOOP, etc. Snowflake Stored Procedures Overview Snowflake stored procedures are used to encapsulate…

Comments Off on Working with Snowflake Scripting Stored Procedures

How to Export Snowflake Table to S3 bucket using DBT?

As cloud data warehouses are gaining popularity, new tools are emerging to interact with them. One of such tool is a Data Built Tool (DBT). DBT is a data transformation tool that focuses on the Transformation part in ELT (Extract, Load, Transform) processes. It supports data warehouses such as Snowflake, Redshift, BigQuery, Databricks, etc. In this article, we will check how to export your Snowflake table to S3 bucket using dbt. What is DBT and How it Works? Before jumping into the approach on exporting Snowflake table to AWS S3…

Comments Off on How to Export Snowflake Table to S3 bucket using DBT?

How to Use Translate Function in Snowflake?

The Snowflake TRANSLATE function returns a string with all occurrences of each character in a string replaced by its corresponding character in the replacement string. For example, you can use Snowflake translate function to replace '#' with a '@' symbol and remove '$' from input string in one operation. The translate is one of the commonly used Snowflake string functions. In this article, we will check how to use the Translate function in the Snowflake cloud database. Snowflake Translate Function Example Translate Function in Snowflake As discussed in the previous example,…

Comments Off on How to Use Translate Function in Snowflake?