Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Tablas planas (https://www.clubdelphi.com/foros/forumdisplay.php?f=20)
-   -   Compactar BD Paradox (como un pack) (https://www.clubdelphi.com/foros/showthread.php?t=30786)

h2o_mx 19-04-2006 11:03:25

Compactar BD Paradox (como un pack)
 
Saludos amigos, quisiera saber como le hago para compactar
unas tablas que tengo en un programa, tengo varias
tablas en las que borro constantemente mientras se
usa el programa, algo asi como la lista de compra
de cada cliente, al final de cuentas queda en blanco.

pero supongamos que cada registro ocupa 30 bytes
y en todo el dia hay una insercion de aproximandamente
unos 10000 registros, mismos que se borran.

y cuando checo el archivo tiene un tamaño fisico de
300000 bytes, lo abro con el DataDesktop y no hay nada,
pero lo abro con el VisualFox y estan todos los registros
que se usaron, desde Fox le hago un pack y me borra todos
esos registros inservibles. (osea que hay un borrado logico
pero no fisico en realidad).

como puedo hacer eso pero desde delphi (manejo version 7).

Gracias y espero que me halla dado a entender.Saludos

Lepe 19-04-2006 11:58:44

Necesitarás el programa CAERQUES para eso, aunque en estos momentos no está disponible la sección Ejemplos. intenta una búsqueda en google y mira este enlace: http://www.clubdelphi.com/foros/show...light=caerques

saludos

egostar 19-04-2006 18:06:37

Checa este link de Delphi Corner te muestra como hacer el Pack Table y es un código que puedes pegar en tu aplicación.

Saludos.

h2o_mx 20-04-2006 09:21:13

gracias amigos, le voy a dar una
checadita, muchas gracias :cool: :cool:

h2o_mx 20-04-2006 09:52:34

saludos de nuevo amigos, tengo el siguiente codigo
que me diste en el link

Código Delphi [-]
procedure PackTable(TblName : String);var  tbl     : TTable;  cProps  : CURProps;  hDb     : hDBIDb;  TblDesc : CRTblDesc;begin  tbl := TTable.Create(nil);  with tbl do begin    Active := False;    DatabaseName := ExtractFilePath(TblName);    TableName := ExtractFileName(TblName);    Exclusive := True;    Open;  end;  // Added 23/7/2000 to make sure that the current path is the same as the table  //see note below  SetCurrentDir(ExtractFilePath(TblName));  // Make sure the table is open exclusively so we can get the db handle...  if not tbl.Active then    raise EDatabaseError.Create('Table must be opened to pack');  if not tbl.Exclusive then    raise EDatabaseError.Create('Table must be opened exclusively to pack');  // Get the table properties to determine table type...  Check(DbiGetCursorProps(tbl.Handle, cProps));  // If the table is a Paradox table, you must call DbiDoRestructure...  if (cProps.szTableType = szPARADOX) then    begin      // Blank out the structure...      FillChar(TblDesc, sizeof(TblDesc), 0);      // Get the database handle from the table's cursor handle...      Check(DbiGetObjFromObj(hDBIObj(tbl.Handle), objDATABASE, hDBIObj(hDb)));      // Put the table name in the table descriptor...      StrPCopy(TblDesc.szTblName, tbl.TableName);      // Put the table type in the table descriptor...      StrPCopy(TblDesc.szTblType, cProps.szTableType);      // Set the Pack option in the table descriptor to TRUE...      TblDesc.bPack := True;      // Close the table so the restructure can complete...      tbl.Close;      // Call DbiDoRestructure...      Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, False));    end  else    // If the table is a dBASE table, simply call DbiPackTable...    if (cProps.szTableType = szDBASE) then      Check(DbiPackTable(tbl.DBHandle, tbl.Handle, nil, szDBASE, True))    else      // Pack only works on Paradox or dBASE; nothing else...      raise EDatabaseError.Create('You can only pack Paradox or dBase tables!');  with tbl do begin    if Active then      Close;    Free;  end;end;

pero en las variables
var
tbl : TTable;
cProps : CURProps;
hDb : hDBIDb;
TblDesc : CRTblDesc;
no reconoce CURProps, ni hDBIDb, ni CRTblDesc, disculpa
mi ignorancia :D , pero tengo que incluir una libreria
o un type? gracias, por lo visto a esta funcion solo le mando
la tabla y ya verdad? osea la mando llamar como:

PackTable('c:\tablas\aquiesta.db'); ????

Thanks!!! :cool: :cool:

egostar 21-04-2006 03:06:53

Cita:

Empezado por h2o_mx
pero en las variables

var
tbl : TTable;
cProps : CURProps;
hDb : hDBIDb;
TblDesc : CRTblDesc;
no reconoce CURProps, ni hDBIDb, ni CRTblDesc, disculpa
mi ignorancia :D , pero tengo que incluir una libreria
o un type? gracias, por lo visto a esta funcion solo le mando
la tabla y ya verdad? osea la mando llamar como:

PackTable('c:\tablas\aquiesta.db'); ????

Thanks!!! :cool: :cool:

Necesitas poner BDE en el USES del programa.

y si debes de usar todo el path de tu tabla, 'c:\tablas\aquiesta.db'


La franja horaria es GMT +2. Ahora son las 21:47:15.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi