From the course: Intro to Snowflake for Devs, Data Scientists, Data Engineers
Unlock this course with a free trial
Join today to access over 24,600 courses taught by industry experts.
Stored procedures: Part 2 - Snowflake Tutorial
From the course: Intro to Snowflake for Devs, Data Scientists, Data Engineers
Stored procedures: Part 2
- In the last video, we learned a bunch about stored procedures and how they compare to UDFs. But now, let's get to the fun part, making our own stored procedure. In our case, let's work with some Tasty Bytes data we haven't looked at before, the transaction data. This spans two tables, ORDER_HEADER, which is basic info about the order, one row per order, and ORDER_DETAILS, which has a row per item per order. So if someone ordered multiple items in a single order, each item would be in a different row. Here, we'll work with ORDER_HEADER, and let's pretend that for some reason, we didn't want to store data older than 180 days, and every day, we want to delete that older data. Stored procedures are perfect for this kind of thing. (dramatic whooshing) Let's take a look at the ORDER_HEADER table. SELECT * FROM FROSTBYTE_TASTY_BYTES_CLONE.RAW_POS ORDER_HEADER. You can see that it's got the order ID, the truck ID, the location and more. The column we care about most here is this ORDER_TS…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.