I have a task that is set as follow:
CREATE OR REPLACE TASK db.schema.task_name
WAREHOUSE = WH_NAME
USER_TASK_TIMEOUT_MS = XXXX
SCHEDULE = 'USING CRON 0,30 * * * * America/Santiago'
WHEN SYSTEM$STREAM_HAS_DATA('db.schema.stream_1') OR SYSTEM$STREAM_HAS_DATA('db.schema.stream_2') OR SYSTEM$STREAM_HAS_DATA('db.schema.stream_3')
AS
EXECUTE IMMEDIATE $$
DECLARE
value_1 INTEGER;
respose STRING;
stream_result resultset DEFAULT (<query_1>);
query_result resultset DEFAULT (<query_2>);
c1 CURSOR FOR query_result;
BEGIN
FOR row_variable IN c1 DO
value_1 := row_variable.count;
END FOR;
...
I have two questions, first, is there any way in which after the tasks enter his code because one of those streams has data, theres a way to know which one is it the one that fulfilled the condition? I wouldn’t like to use a nested if for that, maybe theres a more direct way,
second, if i replace that <query_1> with something like ‘SELECT COUNT(*) FROM db.schema.stream_1 and the result is stored in the variable stream_result, the stream is erased?
Thanks