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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ALIAS problem - different folders - different aliases 1

Status
Not open for further replies.

wildcard

MIS
Mar 9, 2001
67
NZ
I have 2 ledgers on the same server in different directories
One services the NZ market and the other services AUSTRALIA.
The file names are common to both directories.

We must move stock between the 2 ledgers.
The Clipper 5.2c manual says 'Fine - just make sure that
unique ALIASes are used for databases with the same names.
So I did what it said... then compiled and ran it...
DO WHILE .T.
folder1="C:\NZ"
folder2="C:\OZY"

SELECT 1
USE &folder1\STOCK ALIAS NZstock SHARED
IF NETERR()
LOOP
ENDIF

SELECT 2
USE &folder2\STOCK ALIAS OZYstock SHARED && line 20
IF NETERR()
LOOP
ENDIF
EXIT
ENDDO
and I got a run-time error 'ALIAS already in use - STOCK'
(error DBCMD/1011) at commented line 20 (see above)

I know I can OPEN and CLOSE the databases as required
but this does not give any security if one or other
of the ledgers decides to run a function that locks
the files and prevents access... so that is not a viable
option.

This is outrageous! lol.
How do we get around this problem please?

Jim




 
Jim,
It probably doesn't help much but your code works here. Just changing the folder and dbf name to my data it opens things fine. I'm using Clipper 5.2e which might make a difference.
Have you tried just running that bit of your code in isolation to see if it works?
You could try:
USE (folder1+"\STOCK") ALIAS NZstock SHARED
in case there is a strange macro problem.

There is a Locks.prg that comes with the Clipper source. The way that you open the files could be a bit inefficient if you open many files, if one falls over then you end up opening them all again. If you need an alias you can modify it thus:

/***
*NetUse(<cDatabase>,<lOpenMode>,<nWaitSeconds>)->lSuccess
*Attempt to USE a database file with optional retry
Last change: IB 08/03/2003 12:55:02
*/
FUNCTION NetUse( cDatabase, lOpenMode, nSeconds ,cAlias )
LOCAL lForever
lForever = (nSeconds = 0)
DO WHILE (lForever .OR. nSeconds > 0)
IF lOpenMode
if pcount() = 4
USE (cDatabase) alias (xalias) EXCLUSIVE
else
USE (cDatabase) EXCLUSIVE
endif
ELSE
if pcount() = 4
USE (cDatabase) alias (xalias) SHARED // Shared
else
USE (cDatabase) SHARED // Shared
endif
ENDIF
IF .NOT. NETERR() // USE succeeds
RETURN (.T.)
ENDIF
INKEY(1) // Wait 1 second
nSeconds -= 1
ENDDO
RETURN (.F.) // USE fails
Ian Boys
DTE Systems Ltd
 
Ian Boys - thank you for your efforts on this matter
I really appreciate your time and trouble.

I already do have a function that takes in parameters for
filename, alias, shared/exclusive, retrytime time, attempts
and it was via this function that my problems occurred.

So I wrote a test without any fancy functions just to
open 2 databases of the same name in different folders
using an ALIAS for the initial datafile and the problem
still persists. Tried it again with an ALIAS for the
second datafile and still the error.
Therefore, there is an inherent or latent program bug in version 5.2C not previously reported (or at least not noticed by me anyhoo way back then when CA were issuing
update notices).

I have solved the problem in typical kiwi fashion!
I have had to rename one set of the files to different
ALIAS filenames before commencing, then rename then under
all conditions (successful completion, partial completion
or complete hardware crash) back to their original names
in their source folder. What a paiin in the butt!

Thank you again - you helped prove that 5.2C cannot
do this thang!

Cheers,
Jim Wild
<jwild@xtra.co.nz>

 
You are correct, there are ecclatant errors and bugs in any clipper 5.2 version older that 5.2e. That's the reason I got any update from CA as soon as they came out (1997 or so for 5.2e?) They are still on file in the ftp site of CA (ftp.cai.com) You'll have to poke around a bit to get the correct subdir, but then after installing you won't regret getting them down!

Goodluck in upgrading
HTH
TonHu

BTW: IMHO 5.2e was the best Clipper ever around ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top