Board index » delphi » BatCopy problem with batchmove

BatCopy problem with batchmove

Hello,

we habe an application under delphi2 using dbase tables.
When I try to create one table from another by the use of a batchmove with
mode=batCopy, the result is a Dbase table. But when I try to open this dbase
Table with Borlands dbd32 I realize that the numeric fields are not properly
declared.

What may be the reason for that?

Thanks in advance and kind regards

Carl

 

Re:BatCopy problem with batchmove


On Tue, 27 Jun 2000 17:25:32 +0200, "Carl Andersbach" <and...@scm.de>
wrote:

Quote
>we habe an application under delphi2 using dbase tables.
>When I try to create one table from another by the use of a batchmove with
>mode=batCopy, the result is a Dbase table. But when I try to open this dbase
>Table with Borlands dbd32 I realize that the numeric fields are not properly
>declared.

>What may be the reason for that?

What you are probably experiencing is that the table structure is not
exactly copied when you're using a TBatchMove in the batCopy mode.
SmallInt fields will have a (4, 0) format and float fields something
like (20, 4).

If you need an exact copy of the table's structure, you could first
create an empty structure and then move the records to this table with
batAppend instead of batCopy.

Here's some code to duplicate a table structure:

  procedure DupTableStruct(SrceTbl: TTable; DestTblName: String);
  var
    TblDesc: CRTblDesc;
    PtrFldDesc, PtrIdxDesc: Pointer;
    CursorProp: CURProps;
  begin
    SrceTbl.Open;
    Check(DbiGetCursorProps(SrceTbl.Handle, CursorProp));
    // Allocate memory for field descriptors
    PtrFldDesc := AllocMem(SizeOf(FLDDesc) * CursorProp.iFields);
    PtrIdxDesc := AllocMem(SizeOf(IDXDesc) * CursorProp.iIndexes);
    try
      Check(DbiGetFieldDescs(SrceTbl.Handle, PtrFldDesc));
      Check(DbiGetIndexDescs(SrceTbl.Handle, PtrIdxDesc));
      FillChar(TblDesc, SizeOf(TblDesc), #0);
      with TblDesc do
      begin
        StrPCopy(szTblName, DestTblName);
        StrCopy(szTblType, CursorProp.szTableType);
        iFldCount := CursorProp.iFields;
        pfldDesc := PtrFldDesc;
        iIdxCount := CursorProp.iIndexes;
        pIdxDesc := PtrIdxDesc;
      end;
      Check(DbiCreateTable(SrceTbl.DBHandle, True, TblDesc));
    finally
      FreeMem(PtrFldDesc);
      FreeMem(PtrIdxDesc);
    end;
  end;

HTH,

Jan

Other Threads