Hi, thanks in advance.
I am working with an array that contains tables that I want to clear out and then refill.
It is working fine until I get to : Val_tier1. at this point I get the message:
“Alias name is already in use”
The file Val_tier1 is the 5th file processed. The only difference is that the previous table val_companycodes has no data input into it. This could happen to any file. If there is no data necessary for this file.
I have also included the code for this procedure. What I am attempting to do is ensure that the alias val_workfile is closed prior to use. I would like to continue using the val_workfile alias because this procedure spawns another procedure to further process changes to the tables and data.
Any suggestions ?
Memory dump of Adeldbldval Array (parcial)
Adelbldval[1,1] “SQL” C
Adelbldval[1,2] “Val_Bancodes” C
Adelbldval[1,3] “vbk.txt” C
Adelbldval[1,4] .T. L
Adelbldval[1,5] “INI”
Adelbldval[1,6] .T. L
Adelbldval[1,7] 100
Adelbldval[4,1] “SQL” C
Adelbldval[4,2] “Val_companycodes” C
Adelbldval[4,3] “vco.txt” C
Adelbldval[4,4] .T. L
Adelbldval[4,5] “INI”
Adelbldval[4,6] .T. L
Adelbldval[4,7] 130
Adelbldval[5,1] “SQL” C
Adelbldval[5,2] “Val_Tier1 ” C
Adelbldval[5,3] “v1.txt” C
Adelbldval[5,4] .T. L
Adelbldval[5,5] “INI”
Adelbldval[5,6] .T. L
Adelbldval[5,7] 140
Here is the procedure:
** ini_delBldVal D
Procedure ini_delbldVal
select VAL_TABLE
go top
copy to array aDelBldVal for val_delbld = .T.
** create an array of tables to be zaped out
ASORT(ADelBldVal,7)
ValCnt = ALEN(aDelBldVal,1)
FOR nCnt = 1 TO ValCnt
if file(curdir()+(trim(aDelBldVal[nCnt,2]))+".dbf")
cInuse = ""
cInUse = Alias()
** just an attempt to close out alias
if cInUse <> ""
select alias()
use
endif
cInuse = ""
cInUse = Alias()
****
** if the file is in the directory create
** the line to open the table into the alias
** of val_workfile
lcDoZAP = "use " + trim(aDelBldVal[nCnt,2]) + " Exclusive alias val_WorkFile"
&lcDoZAP
** remove all records in the table
zap
if file (trim(AdelBldVal[ncnt,3]))
** if there is a text file for this table
** create the append script for the table
** and append
lcDoAppend = "append from " +(trim(adelBldVal[ncnt,3]))+ " delimited with '' with character }"
&lcDoAppend
** Add extra changes to the table.
do val_extra in ini_procs
endif
endif
endfor
release array AdelBldVal
return
**
Thanks
I am working with an array that contains tables that I want to clear out and then refill.
It is working fine until I get to : Val_tier1. at this point I get the message:
“Alias name is already in use”
The file Val_tier1 is the 5th file processed. The only difference is that the previous table val_companycodes has no data input into it. This could happen to any file. If there is no data necessary for this file.
I have also included the code for this procedure. What I am attempting to do is ensure that the alias val_workfile is closed prior to use. I would like to continue using the val_workfile alias because this procedure spawns another procedure to further process changes to the tables and data.
Any suggestions ?
Memory dump of Adeldbldval Array (parcial)
Adelbldval[1,1] “SQL” C
Adelbldval[1,2] “Val_Bancodes” C
Adelbldval[1,3] “vbk.txt” C
Adelbldval[1,4] .T. L
Adelbldval[1,5] “INI”
Adelbldval[1,6] .T. L
Adelbldval[1,7] 100
Adelbldval[4,1] “SQL” C
Adelbldval[4,2] “Val_companycodes” C
Adelbldval[4,3] “vco.txt” C
Adelbldval[4,4] .T. L
Adelbldval[4,5] “INI”
Adelbldval[4,6] .T. L
Adelbldval[4,7] 130
Adelbldval[5,1] “SQL” C
Adelbldval[5,2] “Val_Tier1 ” C
Adelbldval[5,3] “v1.txt” C
Adelbldval[5,4] .T. L
Adelbldval[5,5] “INI”
Adelbldval[5,6] .T. L
Adelbldval[5,7] 140
Here is the procedure:
** ini_delBldVal D
Procedure ini_delbldVal
select VAL_TABLE
go top
copy to array aDelBldVal for val_delbld = .T.
** create an array of tables to be zaped out
ASORT(ADelBldVal,7)
ValCnt = ALEN(aDelBldVal,1)
FOR nCnt = 1 TO ValCnt
if file(curdir()+(trim(aDelBldVal[nCnt,2]))+".dbf")
cInuse = ""
cInUse = Alias()
** just an attempt to close out alias
if cInUse <> ""
select alias()
use
endif
cInuse = ""
cInUse = Alias()
****
** if the file is in the directory create
** the line to open the table into the alias
** of val_workfile
lcDoZAP = "use " + trim(aDelBldVal[nCnt,2]) + " Exclusive alias val_WorkFile"
&lcDoZAP
** remove all records in the table
zap
if file (trim(AdelBldVal[ncnt,3]))
** if there is a text file for this table
** create the append script for the table
** and append
lcDoAppend = "append from " +(trim(adelBldVal[ncnt,3]))+ " delimited with '' with character }"
&lcDoAppend
** Add extra changes to the table.
do val_extra in ini_procs
endif
endif
endfor
release array AdelBldVal
return
**
Thanks