Saludos amigos,
Tengo algunos clientes que todavía tienen una versión antigua de mi sistema que les vendí y cuando me llaman por soporte o para reinstalación opto por actualizarles a la nueva versión. El problema es que, como comprenderán, la nueva versión tiene algunos cambios en las estructuras de las .dbf y yo no puedo recordarlas todas.
Estuve buscando por la red alguna rutina que me permita comparar las estructuras de las dbf de la versión antigua con la nueva pero no hallé nada, así que decidí hacerla yo mismo. La adjunto en este .zip:
La he probado y funciona bien. El escenario para el que esta hecho es el siguiente:
1. Las tablas a comparar están en diferentes directorios.
2. Las tablas a comparar tienen el mismo nombre.
3. Los campos a comparar en cada tabla tienen el mismo nombre.
El tema ahora es que me gustaría poder, con un solo click, actualizar la estructura de la versión antigua del cliente a la nueva, sin perder sus datos originales por supuesto. Cuando trabajé con Clipper 5.2 no recuerdo haber visto ninguna instrucción para alterar directamente el campo de una tabla (tipo,longitud,decimales) por lo que estoy un poco perdido en esa parte. Tal vez alguien con una experiencia similar podría aportar en este utilitario y disponerlo para todos.
Agradeciendo su tiempo envío saludos a todos.
Mil gracias anticipadas.
Comparar estructuras DBF de distintas versiones
Moderator: Rathinagiri
- edufloriv
- Posts: 240
- Joined: Thu Nov 08, 2012 3:42 am
- DBs Used: DBF, MariaDB, MySQL, MSSQL, MariaDB
- Location: PERU
Comparar estructuras DBF de distintas versiones
Eduardo Flores Rivas
LIMA - PERU
- dragancesu
- Posts: 930
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
Re: Comparar estructuras DBF de distintas versiones
Changes in the structure dbf is a big problem
Easy to change with the help of programs like dBase, dbx and similar or software is perhaps best to make the new structure and rewrite means
Make version.dbf which keeps the current version
on start do procedure like this
select version
if version <1.2
upgrade_12 ()
Replace version->version with version 1.2
endif
if version <1.3
uggrade_13 ()
Replace version->version with version 1.3
endif
...
upgrade_nn function (12, 13, ...)
save old structure
create nev structure
Rewrite old to new
return
create new function for new structure version
Easy to change with the help of programs like dBase, dbx and similar or software is perhaps best to make the new structure and rewrite means
Make version.dbf which keeps the current version
on start do procedure like this
select version
if version <1.2
upgrade_12 ()
Replace version->version with version 1.2
endif
if version <1.3
uggrade_13 ()
Replace version->version with version 1.3
endif
...
upgrade_nn function (12, 13, ...)
save old structure
create nev structure
Rewrite old to new
return
create new function for new structure version
- serge_girard
- Posts: 3309
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Comparar estructuras DBF de distintas versiones
Eduardo,
I use this construction to change a dbf a distance:
If a new field (in this case BEG_DAT) doesn't exist the DBSTRUCT is appended with the new field and then created.
Rather simple and you can extend even on lenght and type level if you want or fill in the new field with default values.
Hope this might help!
Serge
I use this construction to change a dbf a distance:
Code: Select all
FUNCTION Create_New_Tables()
/****************************/
FERASE('C:\FOLDER1\K0001_OLD.DBF')
FERASE('C:\FOLDER1\K0001_X.DBF')
use C:\FOLDER1\K0001
aSTRUCT := DBSTRUCT()
lOK7 := FALSE
FOR y := 1 TO LEN(DBSTRUCT())
mFIELD1 := aSTRUCT [y] [1]
mFIELD3 := aSTRUCT [y] [3]
IF UPPER(ALLTRIM(mFIELD1)) == 'BEG_DAT'
lOK7 := TRUE
EXIT
ENDIF
NEXT Y
CLOSE K0001
IF!lOK7
AADD(aSTRUCT, {'BEG_DAT','D',8,0})
DBCREATE( "C:\FOLDER1\K0001_X.DBF" , aSTRUCT )
USE C:\FOLDER1\K0001_x
APPEND FROM C:\FOLDER1\K0001
CLOSE K0001_X
IF FRENAME("C:\FOLDER1\K0001.DBF", "C:\FOLDER1\K0001_OLD.DBF") == -1
MSGINFO('K0001_OLD is blocked; retry', 'K0001 NOK')
ENDIF
IF FRENAME("C:\FOLDER1\K0001_X.DBF", "C:\FOLDER1\K0001.DBF") == -1
MSGINFO('K0001_X is blocked; retry', 'K0001_X NOK')
ENDIF
ENDIF
CLOSE ALL
RETURN
Rather simple and you can extend even on lenght and type level if you want or fill in the new field with default values.
Hope this might help!
Serge
There's nothing you can do that can't be done...
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Comparar estructuras DBF de distintas versiones
Hola Eduardo,
En Stru.prg (aqui en este tópico) vas a encontrar una rutina de importacion cuando se alteran estructura, mismo que el nombre de los campos se cambie.
Talvez sea de utilidad.
Yo creo que basicamente tendrias que obtener las dos estructuras que consiguirás en forma de array y comparar los elementos de los dos array. Vá de tu genialidad en comparan nombres y tamaños.
En Stru.prg (aqui en este tópico) vas a encontrar una rutina de importacion cuando se alteran estructura, mismo que el nombre de los campos se cambie.
Talvez sea de utilidad.
Yo creo que basicamente tendrias que obtener las dos estructuras que consiguirás en forma de array y comparar los elementos de los dos array. Vá de tu genialidad en comparan nombres y tamaños.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein