2 0
Read Time:1 Minute, 15 Second

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.

SHOW TASK

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)

TASK DROP PROC

Now execute the Proc and verify the results:

Proc Output

Verify whether TASKS has been dropped or not.

Task List After Drop

Now TASKS dropped successfully from the system without no manual intervention.

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *