Delete Features Upon Completion of Model

729
3
06-06-2012 01:24 PM
StuartBlumberg
New Contributor II
Hello,

I have a temporary geodatabase where several feature classes are created during the process of a model run.  Once the model completes I would like to delete all the features in this geodatabase without deleting the geodatabase itself.  I have tried simply adding a "delete" tool in model builder after the last process, however, there seems to be a schema lock on the data while the model is still running.  Is there a way around this?  Can I make the delete tool run "on completion of the model?"  Thanks.
0 Kudos
3 Replies
JonathanQuinn
Esri Frequent Contributor
Have you considered using an in_memory workspace?  If you don't need the intermediate data that are created in the geodatabase, you can set the outputs of the data that would've been written to the geodatabase to an in-memory workspace, i.e. a clip could write to in_memory/clip_result.  This clip_result feature layer can then be used in later processes in the model, but after the model finishes, it will be deleted.

One thing to note, if this is an intensive model, in that it creates a lot of intermediate data, you might be better off saving to the geodatabase.  In that case, take a look at the use of intermediate data to manage data that is not needed after the model completes.
0 Kudos
StuartBlumberg
New Contributor II
Thank you for your suggestions, however model builder does not give me the option to set the data in the temporary geodatabase as "intermediate."  Is there another way to delete the data from the geodatabase?  Thank you.
0 Kudos
JonathanQuinn
Esri Frequent Contributor
You can add the Iterate Feature Classes iterator to the end of the model so that will iterate through each feature class and delete them.  Set a precondtion that the final output needs to be created before the iterator runs.
0 Kudos