During this post we will discuss how to drop the TASKS from system. Consider the scenario you have ‘N’ number of TASK exists in system. During the passage of time these TASK are no longer required. As per the ask from Business we need to remove these from Database. Instead of doing it manually, Business wants an automated way. We have thought about Snowflake JavaScript Procedure , which will get the list of all tasks and drop one-by-one programmatically. Proc would be running on adhoc basis and will DROP the TASK without manual interference.
Say we have the following TASKS exists in DEMO_DB database. As we can see 5 TASKS are related to the PHARMA project while other are related to XEROX project.
Our requirement is we want to drop the TASKS belongs to PHARMA only. We have developed the below procedure where we are extracting TASK List belongs to PHARMA only.
show tasks like ‘PHARMA%’;
Now will use the below function to fetch the result of previous executed query.
RESULT_SCAN(LAST_QUERY_ID)
Now execute the Proc and verify the results:
Verify whether TASKS has been dropped or not.
Now TASKS dropped successfully from the system without no manual intervention.