Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3be0ab6

Browse files
Create asynchronous-execution-of-embedded-statements-in-SQL-stored-procedures-in-snowflake.md
1 parent fc7f397 commit 3be0ab6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Asynchronous execution of embedded statements in SQL stored procedures in Snowflake
2+
3+
Snowflake supports `async`/`await` syntactic sugar that allows asynchronous, non-blocking stored procedures to be structured in a way similar to an ordinary synchronous stored procedures.
4+
5+
Here is a sample:
6+
7+
```sql
8+
9+
create or replace table customer_emails (customer_id int, email_address string);
10+
create or replace table order_emails (order_number int, email_address string);
11+
12+
CREATE or replace PROCEDURE sp__async_insert (order_number int, customer_id int, email_address string)
13+
RETURNS string
14+
LANGUAGE SQL
15+
AS
16+
BEGIN
17+
ASYNC (INSERT INTO customer_emails VALUES (:customer_id, :email_address));
18+
ASYNC (INSERT INTO order_emails VALUES (:order_number, :email_address)) ;
19+
AWAIT ALL;
20+
END
21+
;
22+
23+
call sp__async_insert(111, 123, 'name@domain.tld');
24+
select * from customer_emails;
25+
select * from order_emails;
26+
27+
```
28+
29+
30+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /