Page 1 of 1
From Adt to Dbf
Posted: Mon Jan 18, 2021 3:46 pm
by rubenfernandez01
Hi friends.
How to create a dbf table from adt (ADS) table.
There's something automatic.?
Thank you.
Saludos.
Enviado desde mi Redmi Note 8 Pro mediante Tapatalk
Re: From Adt to Dbf
Posted: Mon Jan 18, 2021 4:41 pm
by carlos vargas
Code: Select all
USE NOMTABLA0 NEW ALIAS CTRL
...
USE NOMTABLA10 NEW ALIAS CXDT
...
Adt2Dbf()
...
Code: Select all
PROC Adt2Dbf()
//RddSetDefault( "DBFCDX" )
SELECT CTRL
Mig("control")
SELECT USUA
Mig("usuarios")
SELECT FERI
Mig("feriados")
SELECT PLAZ
Mig("plazos")
SELECT ZONA
Mig("zonas")
SELECT CIUD
Mig("ciudades")
SELECT GEST
Mig("gestores")
SELECT COBR
Mig("cobradores")
SELECT RUTA
Mig("rutas")
SELECT CLIE
Mig("clientes")
SELECT PROG
Mig("programacion")
SELECT PBAK
Mig("programacion_bak")
SELECT PRES
Mig("prestamos")
SELECT DIFE
Mig("diferidos")
SELECT MOVI
Mig("movimientos")
SELECT FLUJ
Mig("flujos")
SELECT MCXR
Mig("mcobrosxruta")
SELECT DCXR
Mig("dcobrosxruta")
SELECT CAJA
Mig("caja")
SELECT CXDI
Mig("cobroxdia")
SELECT CXDC
Mig("cobroxdiac")
SELECT CXDT
Mig("cobroxdiat")
RddSetDefault( "ads" )
RETURN
PROC Mig(cTabla)
LOCAL cOldAlias := Alias()
LOCAL xT,xT1
LOCAL aTab
LOCAL n,o,i
aTab := DBStruct()
FOR x:=1 TO Len( aTab )
IF aTab[ x, 2 ]="D"
aTab[ x, 3 ]=8
ENDIF
NEXT
DbCreate( "d:\dbc\" + (cTabla), aTab, "DBFCDX", .T. )
USE ( "d:\dbc\" + (cTabla) ) ALIAS TEMP VIA "dbfcdx"
// SELECT (cAlias)
//
// n:=1
// DO WHILE .T.
// IF Empty( OrdName(n) )
// EXIT
// ENDIF
// TRY
// TEMP->( OrdCondSet((cAlias)->( OrdFor(n)),,.t.,,,, nil, nil, nil, nil,, nil, .F., .F., .F., .F.))
// TEMP->( dbGoTop() )
// TEMP->( ordCreate(,(cAlias)->( OrdName(n) ), (cAlias)->( OrdKey(n) ), &("{||"+(cAlias)->( OrdKey(n) )+"}") ))
// CATCH o
// SELECT (cAlias)
// ?cTabla,(cAlias)->( OrdName(n) ), (cAlias)->( ordKey(n) )
// END
// ++n
// ENDDO
SELECT ( cOldAlias )
WaitOn("Procesando: " + cTabla )
i:=0
GO TOP
DO WHILE !Eof()
TEMP->( DBAppend() )
FOR x:=1 TO FCount()
xT := FieldGet( x )
TEMP->( FieldPut( x, xT ) )
NEXT
SKIP
IF Mod( ++i, 100 )=0
SysRefresh()
ENDIF
ENDDO
WaitOff()
TEMP->( DBCloseArea() )
SELECT (cOldAlias)
RETURN
Re: From Adt to Dbf
Posted: Mon Jan 18, 2021 5:25 pm
by D.Fernandez
Gracias Carlos.
Impresionante.
Estoy comenzando con Mysql y por las dudas se corta la conexion
dejo a una PC trabajando con los dbf.
Gracias, saludos.
Re: From Adt to Dbf
Posted: Tue Jan 19, 2021 4:09 pm
by nageswaragunupudi
If the ADT file contains only fields of types "+CDLNTM", then this works
Code: Select all
USE CUSTADT NEW VIA "ADSADT" // "ADT" in xHarbour
COPY TO CUSTDBF VIA "DBFCDX"
Re: From Adt to Dbf
Posted: Tue Jan 19, 2021 4:22 pm
by nageswaragunupudi
Small sample converting CUSTOMER.DBF to CUSTADT.ADT and then back to CUSTDBF.DBF
Code: Select all
#include "fivewin.ch"
#include "ads.ch"
REQUEST DBFCDX
REQUEST ADSKEYCOUNT, ADSGETRELKEYPOS, ADSSETRELKEYPOS, ADSKEYNO
static cRddADT
function main()
local aStruct
RddRegister( "ADS", 1 )
AdsSetServerType( ADS_LOCAL_SERVER )
cRddAdt := If( AScan( RddList(), "ADSADT" ) > 0, "ADSADT", "ADT" )
// DBF TO ADT
aStruct := FW_DBFSTRUCT( "CUSTOMER.DBF" ) // no need to open the dbf
AEval( aStruct, { |a| If( a[ 2 ] == "N", a[ 3 ] += 1, ) } )
DBCREATE( "CUSTADT.ADT", aStruct, cRddAdt, .t., "DST" )
APPEND FROM CUSTOMER VIA "DBFCDX"
GO TOP
XBROWSER
// ADT TO DBF
GO TOP
COPY TO CUSTDBF VIA "DBFCDX"
CLOSE DATA
USE CUSTDBF VIA "DBFCDX"
XBROWSER
return nil
Re: From Adt to Dbf
Posted: Wed Jan 20, 2021 12:42 am
by D.Fernandez
Thank you Mr. Rao.
Excellent.
I'm trying to convert a app using only Fwh with Mysql, a dbf/cdx.
Until now it's ok.
Thank you very much.
Saludos..Ruben Dario Fernandez