I’m trying to test a small script in snowflake that performs housekeeping on a couple of tables, but the script is terminating with Syntax error: unexpected 'DELETE'
error.
My script is:
DECLARE
AnalysisDate DATE;
HouseKeepingDate DATE;
RetentionDays INT;
AnalysisDate := '2024-06-27';
RetentionDays := 28;
HouseKeepingDate := DATEADD(DAY, -:RetentionDays, :AnalysisDate);
DELETE t
FROM PREP.STOCK_ADJUSTMENTS AS t
WHERE ANALYSIS_DATE < :HouseKeepingDate;
DELETE t
FROM PREP.BOOK_STOCK AS t
WHERE ANALYSIS_DATE < :HouseKeepingDate;
I get the same error with or without putting in the table alias.