Syntax

Like any other object, a dynamic ProDataSet should be deleted when you are finished using it. Otherwise it continues to use memory and other resources, and since a ProDataSet can be quite large, this can be significant. When a ProDataSet is passed remotely, and therefore copied, the called procedure must be prepared to delete it if it is received as a dynamic ProDataSet. As we have discussed, however, the same procedure call could be used between two procedures in the same session, and you would not want to inadvertently delete a ProDataSet that is passed by reference in a local call and therefore actually "owned" by another procedure.

In order to simplify this, you can use the DELETE OBJECT statement in the called procedure when it uses a DATASET-HANDLE. This is the syntax for the DELETE OBJECT statement:

DELETE OBJECT dataset-handle NO-ERROR.

In this way, the ProDataSet is deleted when appropriate. The NO-ERROR keyword suppresses any error message if the object has already been deleted (in which case dataset-handle is no longer a valid handle).

Also, this statement does not delete a ProDataSet object when the ProDataSet is passed locally and by reference, which means that the ProDataSet is not owned by the procedure attempting the delete. To work around this behavior, use the Dataset By-Reference Delete (-dsetbyrefdelete) startup parameter. Take care when using this startup parameter. Ensure that the ProDataSet you are about to delete is not being used by any other procedure or method.