UDA-SQL-0107 A general exception has occurred during the operation 'fetch'

Problem
A Query Studio report with Date prompt. When small date range(14 days) is selected then report comes back fine, but when large date range (2 months) is selected the report errors out.

Symptom
UDA-SQL-0114 The cursor supplied to the operation ‘sqlOpenResult’ is inactive.
UDA-SQL-0107 A general exception has occurred during the operation ‘fetch’.
Unable to retrieve result from data source ‘sales’ during query execution. Failed query:

Database: Sybase

Solution
Found out that if we run the query on database directly for large result set the query was filling up the database temp space whereas it was not filling up for small result set. To resolve the issue, either allocate more temp space for the DB or limit the date range selection.