>I have a single user DOS application which I am now allowing to have a second user with read only rights. Some temporary tables created with sql selects (a cursor won't do since I need to chage some fields) have fixed names and sometimes lead to "sharing violation" errors in Windows 95. Since the goal is not to have to change too much of the code, I need to trap these errors, but don't know how to do it does anybody know how ?
If you're using FPD, you may use Filer to look for "into table", and locate all the places where this happens, then replace real table names with name expressions, or make them cursors and add a line to use the cursors again, when they became read-write. Thus, two approaches, supposing you have a command like
Select .... into table dbfname
In first scenario, this becomes
tempname=sys(3)
Select ... into table (tempname)
use (tempname) alias dbfname
In the other scenario
select ... into cursor anyothername
use (dbf()) again in 0 alias dbfname
select dbfname
That's all you have to change. Not too much work in both cases; I'd prefer cursors, because they're, by default, created on your temp drive, i.e. not on the server machine (check the config.f* settings on both machines for tmpfiles, sortwork, editwork, progwork), and they're automatically deleted when you close them, keeping the system free of unnecessary files. In cases where the selected data are to be used later, then it'll be tables, of course, but then you must take care that either their names (or location) be different for each user, or use the error routine as described in the rest of this thread.