Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select statement leaves table in use.
Message
From
25/01/2009 09:45:13
 
 
To
25/01/2009 08:33:07
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01376809
Message ID:
01376844
Views:
11
>>>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                                  && close in reverse order they were opened.
>                        do case
>                        case upper(aNow[i,1]) == upper(Alias())               && skip if resulting cursor
>                        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.
>
>
>*-- create snapshot of currently open tables.
>local loOpen
>loOpen = CreateObject("CloseTemp")
>*-- perform query
>Select * from file1 join file2 on ... into cursor temp
>*-- close all files open during the query, but the current cursor.
>release loOpen
>
if with is not active:
*-- create snapshot of currently open tables.
WITH CreateObject("CloseTemp")
*-- perform query
Select * from file1 join file2 on ... into cursor temp
*-- close all files open during the query, but the current cursor.
ENDWITH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform