Subject Re: Release temporary table
From Mervyn Bick <invalid@invalid.invald>
Date Thu, 8 Nov 2018 16:56:46 +0200
Newsgroups dbase.getting-started

On 2018-11-08 3:43 PM, Randy Waldman wrote:
> Plus 12 user.  I have a program that loops and creates a report with a temporary table.  Second time that I try to run the report, I get an error that my TempTable is "in use by another".  How do I free my TempTable for re-use?
> thanks, Randy
>

You haven't really given enough detail so this will have to be very
general.

A lot depends on how and where you are creating the temporary table and
how you are running the report.

If you are running the report with DO REPORT.REP the problem is unlikely
to be in the report.  When the report closes its query will be destroyed
and the table will be released.  If you get the error under these
circumstances the problem is in the program that creates the temporary
table.  Make sure that you deactivate the query once the temporary table
has been created.

If you are using a program (or form) to load the report into memory
using SET PROCEDURE... and then create an instance of the report i.e
form.oRep = new reportreport()  you need to deactivate the query in the
report before you can recreate the table.  Something like

   form.oRep.render()
   form.oRep.queryname.active = false

Now you can rebuild the table.  Before you render the report you will
need to make its query active again.


   form.oRep.queryname.active = true
   form.oRep.render()

There are cases where the only solution is to create a temporary table
but in most cases a little bit of SQL can produce the required rowset
from the main tables.

Mervyn.