> Why, using delete method with a DB3-DBIV-DBase7, have I only a logical
> delete and not a physical delete?
Hi,
That's how it works with dbase. You can pack the table for physical
delete.
Cheers,
Bogdan
Bogdan Pop wrote:
What is the method to pack tables?
Bogdan Pop wrote:
Thanks Ettore!!!
Use the DbiPackTable BDEAPI function.
Ex: DbiPackTable (table1.dbhandle, table1.handle,'','',true) ( add bde in
uses clause and set exclusive to true for the table)
Regards,
Bogdan
>Why, using delete method with a DB3-DBIV-DBase7, have I only a logical
>delete and not a physical delete?
dBASE tables use what is referred to as a "soft delete." When a record in a
dBASE table is "deleted," it is not physically removed from the table.
Instead, it is marked as deleted by the placement of an asterisk (ASCII
decimal 42) in the first byte of the record. The record is then suppressed
for data operations (searches, counts, filtering, etc.). To physically
remove such marked records from the table, it is necessary to perform a
PACK operation (named after the dBASE command for this operation).
In Delphi, the TTable component only supports those operations common to
all table types supported, ommitting those features that are specific to
only one table type. This allows for having only one TTable object, as
opposed to multiple TTable objects: one for each table type.
Because the soft delete is one of those specialized features found only in
the dBASE table, Delphi itself includes no provision for this operation.
However, the Borland Database Engine (BDE) does. BDE API functions can be
called from Delphi applications, making the use of these functions
available even though Delphi does not include them directly. The PACK
operation is effected with the BDE API function DbiPackTable.
Below is an example of the DbiPackTable in use in a Delphi unit. This
example includes a demonstration of BDE error checking. BDE functions
return a value of type DBIResult that indicates the success or failure of
the function call, no error message will be generated by the BDE so this is
the only way to assess success. Any result but DBIERR_NONE indicates a
failure. With many BDE functions, failed calls cause a different return
code for different reasons for the failure. The various failure error codes
for the DbiPackTable function are demonstrated below.
unit Pack_1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Grids, DBGrids, DB, DBTables,
BDE;
type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
Error: DbiResult;
ErrorMsg: String;
Special: DBIMSG;
begin
table1.Active := False;
try
Table1.Exclusive := True;
Table1.Active := True;
Error := DbiPackTable(Table1.DBHandle, Table1.Handle, nil, szdBASE,
True);
Table1.Active := False;
Table1.Exclusive := False;
finally
Table1.Active := True;
end;
case Error of
DBIERR_NONE:
ErrorMsg := 'Successful';
DBIERR_INVALIDPARAM:
ErrorMsg := 'The specified table name or the pointer to the ' +
'table name is NULL';
DBIERR_INVALIDHNDL:
ErrorMsg := 'The specified database handle or cursor handle is ' +
'invalid or NULL';
DBIERR_NOSUCHTABLE:
ErrorMsg := 'Table name does not exist';
DBIERR_UNKNOWNTBLTYPE:
ErrorMsg := 'Table type is unknown';
DBIERR_NEEDEXCLACCESS:
ErrorMsg := 'The table is not open in exclusive mode';
else
DbiGetErrorString(Error, Special);
ErrorMsg := '[' + IntToStr(Error) + ']: ' + Special;
end;
MessageDlg(ErrorMsg, mtWarning, [mbOk], 0);
end;
end.
For any unit making a call to BDE API functions, you must include the BDE
wrapper unit named BDE in the Uses section.
//////////////////////////////////////////////////////////////////////////
Steve Koterski "My problem lies in reconciling my gross
Technical Publications habits with my net income."
INPRISE Corporation -- Errol Flynn (1909-1959)
http://www.borland.com/delphi