select 1
use ( oldtable ) via "dbfcdx" excl
select 2
use ( temp ) via "dbfcdx" excl
select 1
go top
Do while .not. eof()
select 2
append blank
// append your fields here
select 1
skip
End Do
CLose databases
ferase( "OldTable" )
Rename ( Temp ) to ( oldtable )
if valtype(field->RATE) == "C" [b]// if rate is "C" need to make "Numeric"
[/b]
copy to atemp3 structure extended
use atemp3
append blank // when I append blank it adds another field with the same name.
replace field_name with "rate",field_type with "numeric",field_len with 18, field_dec with 6
create atemp9 from atemp3
use atemp9 alias atemp9
append from (gld)
atemp9->(dbclosearea())
erase (gld)
rename atemp9.dbf to (gld) //"gl.d"+cEntity
endif
Local nType
select 1
Use ( "OldTable.dbf" ) via "DBFCDX" Shared // test in shared first
nType := valtype( a->fieldinquestion)
Close databases
If nType = "N"
_Update()
Else
CLose Databases
Endif
//--------------
Static Func _Update()
Local DBFSTRU
DBF_STRU := { }
AADD( DBF_STRU, { "FIELD1", "C", 18, 0 } )
AADD( DBF_STRU, { "FIELD2, "C", 30, 0 } )
AADD( DBF_STRU, { "FIELDTOCHANGE", "N", 1, 6 } ) // was char in orig table
//.. add the rest or your fields from the orig table here
)
DBCREATE( TEMP.DBF, DBF_STRU )
Select 1
Use ( "OldTable.dbf" ) via "DBFCDX" Excl
Select 2
Use ("Temp.dbf") via "DBFCDX" Excl
Select 1
Go Top
Do While .not. eof
select 2
append blank
b->field1 := a->field1
b->field2 := a->field2
b->FIELDTOCHANGE := val(a->oldfield) // may have to convert to val with dec
select 1
skip
Enddo
CLose databases
ferase( "OldTable.dbf" )
rename ( "temp.dbf" ) to ( "OldTable.dbf" )
Return(.t.)
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 63 guests