>>Is there a way from keeping a SQL Select statement from leaving the tables open that is pulls from?
>>
>>I'm annoyed that if the tables are not already opem, it will open them (which is fine), but it leaves the tables open (i.e. USED).
>>
>>I wish it would close them back. Right now, I am doing a USE IN statement on about 4 tables to close them due to having been opended by a SQL Select statement.
>
>Check
Class to close any cursors created after it was instantiated FAQ #31943
>
>So, you would instantiate this class before the select, then release it.
This suggestion is the same as I was about to give.
But, two thing should be included.
1) Be sure to remove thea reference to the resulting cursor from the second AUSED array before closing the tables/cursors.
2) The array created by AUSED is order in the order from how they are opened. To prevent any dependencies, close them in reverse order.
See revised code.
Define Class CloseTemp As Custom
Dimension a1[1]
nFiles=0
Procedure Init
This.nFiles=Aused(atemp)
If This.nFiles>0
Acopy(atemp, This.a1)
Else
This.a1=""
Endif
Procedure Destroy
For i=Aused(aNow) to 1 Step -1
do case
case upper(aNow[i,1]) == upper(Alias())
case Ascan(This.a1, aNow[i,1],-1,-1,1,2+4)=0
Use In aNow[i,1]
Endcase
Endfor
Enddefine
Here is a sample code as I see what Matt is attempting.
local loOpen
loOpen = CreateObject("CloseTemp")
Select * from file1 join file2 on ... into cursor temp
release loOpen
Greg Reichert