>I would like to create a new private datasession for a common module in order to isolate database changes this module will make from the calling module.
You can code the module as a class based on Session base class, then to use it just instantiate the class and call methods. Or you can store the value of SET("DATASESSION") to a var, instantiate a private-datasession object with
myObj = CREATEOBJECT("Session)
then
SET DATASESSION TO myObj.DataSessionID
and when done, set the datasession back to the original.
I much prefer the first approach of coding as a class based on Session because you don't have to explictly change the datasessions. The Session-based class starts up in a private session and that session goes away when the object is released. You can do ANY data commands inside that session (including CLOSE DATABASES, etc) without affecting anything outside the session.
However, you should be aware that some environment settings that are scoped to DataSession must be set in the Session's Init, so I usually have an AppSession subclass of Session with the proper stuff in the Init available to instantiate if I need to use the second approach above, and also to subclass from if using the first approach.