Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unique Names for Temporary Tables used for Reports 2

Status
Not open for further replies.

LeonelSanchezJr

Programmer
Jan 26, 2001
522
US
I created some reports in a Visual FoxPro 6.0 environment, but my users can not run the same report simultaneously because of the temporary tables / queries that my program creates.

How can I modify this to be multi-user compatible?

Is there a command that would allow me to assign a unique filename to each table / query?
 
SYS(2015) will give you a unique name.

HTH,
Weedz (Wietze Veld) They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best. - Steve McConnell
 
The file name creation using SYS(2015) certainly will work. However you may want to consider the following. I have to support win95 and win2000. Depending on how win2000 permissions are set, the default path can be tricky. I use the following code to point me to the correct path for either 95 or 2000 and then use what ever file name that I want to use. This is truly multi user, irrespective of the user's permission level, and in case serveral users share the same workstaton

PUBLIC gcW2KPath
gcW2KPath = IIF(SUBSTR(OS(),9,1) = "5", ;
"C:\Documents and Settings\"+substr(SYS(0),RAT("#",SYS(0))+2)+"\Local Settings\Temp\","C:\Windows\Temp\")

I put this code in the main.prg or where ever is top level and then use the gcW2KPath tempfile (or SYS(2015))construct to create a file name that will be consistent and compatible with any O/S.
 
I have encountered the same problem w/ temporary tables and I have used SYS(3) to solve it.

SYS(3) - Returns a unique, legal file name that can be used to create temporary files.

WHILE ->

SYS(2015) - Returns a unique 10-character procedure name that begins with an underscore followed by a combination of letters and numbers.

Remarks
- A different file name is returned each time SYS(3) executes.

:)
 
You need to be carefull if you use SYS(3) several times right in a row because on the faster PCs, the file names are not always unique. We have started using a combination of SYS(3) and SYS(2015).
 
You can also create your query results as a cursor:

SELECT * FROM table1 INTO CURSOR mycursor

The cursor mycursor will be unique to each user.

Jim
 
When messing with temporay files in the past, I've found the best solution for shared applications is to set the temporay files path in vfp to a directory on the users local driver (like c:\temp).

You then always preceed any temparary file names that you create with this path. SYS(2023) returns the path where foxpro stores it's temporary files.

Unless you have the application running twice on one PC, you'll have no problem.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top