Expand my Community achievements bar.

SOLVED

Anonymous Block Query Service

Avatar

Level 7

Hi there, 

 

How do I use the Anonymous block feature in SQL query as noted in this documentation https://experienceleague.adobe.com/docs/experience-platform/query/sql/syntax.html?lang=en#anonymous-... 

 

I copied a bit of the query from the documentation above:

$$BEGIN
SET @v_snapshot_from = select parent_id from (select history_meta('email_tracking_experience_event_dataset') ) tab where is_current;
SET @v_snapshot_to = select snapshot_id from (select history_meta('email_tracking_experience_event_dataset') ) tab where is_current;
SET @v_log_id = select now();
$$END;

 

And it's throwing me this error message:

ErrorCode: 42601 queryId: 1620a552-714a-4e8c-9cd9-efd0c5ded092 Syntax error encountered. Reason: [line 1:1: mismatched input '$' expecting {<EOF>, '(', 'ABORT', 'ALTER', 'ANALYZE', 'BEGIN', 'CALL', 'CLOSE', 'COMMIT', 'COPY', 'CREATE', 'DEALLOCATE', 'DECLARE', 'DELETE', 'DESC', 'DESCRIBE', 'DROP', 'EXECUTE', 'EXPLAIN', 'FETCH', 'GRANT', 'INSERT', 'MERGE', 'PREDICT', 'PREPARE', 'RESET', 'REVOKE', 'ROLLBACK', 'SELECT', 'SET', 'SHOW', 'START', 'SYNC', 'TABLE', 'USE', 'VALUES', 'VANISH', 'WITH'}]

 

Thanks

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 1

Hi @akwankl,

 

It seems like a typo in the documentation but the anonymous block should be closed with $$;

 

$$BEGIN
SET @v_snapshot_from = select parent_id from (select history_meta('email_tracking_experience_event_dataset') ) tab where is_current;
SET @v_snapshot_to = select snapshot_id from (select history_meta('email_tracking_experience_event_dataset') ) tab where is_current;
SET @v_log_id = select now();
END$$;

 

Thanks !

View solution in original post

1 Reply

Avatar

Correct answer by
Level 1

Hi @akwankl,

 

It seems like a typo in the documentation but the anonymous block should be closed with $$;

 

$$BEGIN
SET @v_snapshot_from = select parent_id from (select history_meta('email_tracking_experience_event_dataset') ) tab where is_current;
SET @v_snapshot_to = select snapshot_id from (select history_meta('email_tracking_experience_event_dataset') ) tab where is_current;
SET @v_log_id = select now();
END$$;

 

Thanks !