2

As per the official documentation, it depicts as though we can insert into multiple tables from a task. Which sounds inaccurate since

  • Once consumed the offsets of the stream are reset
  • It is possible to execute only one SQL statement from a task

am I missing something here? I want to be able to insert into 2 tables reading out of a stream through the task.

multiple tables

Somasundaram Sekar
  • 5,244
  • 6
  • 43
  • 85

2 Answers2

2

You can do this with a multi-table insert:

https://docs.snowflake.com/en/sql-reference/sql/insert-multi-table.html

Greg Pavlik
  • 10,089
  • 2
  • 12
  • 29
2

You can do this. Multi-table inserts are one way, but there is another.

The pointer in the stream is only advanced at the end of a transactions. Therefore, you can enclose multiple DML statements that read from the stream in a single transaction. Unfortunately, tasks can only execute a single SQL statements, so you will have to embed your queries in a stored procedure.

Hope this helps.

Marius
  • 208
  • 5
  • 14