<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def detach(self, sync=True):
 """ Detach this result from its parent session by fetching the remainder of this result from the network into the buffer. :returns: number of records fetched """

        if self.attached():
            return self._session.detach(self, sync=sync)
        else:
            return 0