SQL Management of status codes

expanded switch case and scheduletask has been given a small if check
for the status code is active or not.