Solved

DbiWriteBlock example

Posted on 1998-02-02
5
252 Views
Last Modified: 2010-04-04
Does any one have an example using the DbiWriteBlock?
0
Comment
Question by:ronit051397
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1358114
The one from the DBE help file? :

Add multiple records to a table

This example assumes that the Customer TTable object is the Customer.DB table. It uses the following input:      fDbiWriteBlock(Table1; NumRecs);

procedure fDbiWriteBlock(Customer: TTable; var RecordsToInsert: Longint);
var
  pRecordsBuf, pTmpBuf: pBYTE;
  Rec: longint;
  CustNo: double;

begin
  Randomize;
  GetMem(pRecordsBuf, Customer.RecordSize * RecordsToInsert);
  pTmpBuf := pRecordsBuf;
  try
    for Rec := 1 to RecordsToInsert do
    begin
      CustNo := Random(1000000);
      // Iterate through the entire record buffer filling each individual record with information
      with Customer do
      begin

        Check(DbiInitRecord(Handle, pTmpBuf));
        Check(DbiPutField(Handle, FieldByName('CustNo').Index + 1, pTmpBuf,
                pBYTE(@CustNo)));
        Check(DbiPutField(Handle, FieldByName('Company').Index + 1, pTmpBuf,
                PChar('Borland International')));
        Inc(pTmpBuf, RecordSize);
      end;
    end;
    Check(DbiWriteBLock(Customer.Handle, RecordsToInsert, pRecordsBuf));
  finally
    FreeMem(pRecordsBuf, Customer.RecordSize * RecordsToInsert);

  end;
end;
0
 
LVL 5

Author Comment

by:ronit051397
ID: 1358115
How do I use DbiAppendRecord instead of DbiPutField?

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1358116
?
DBiWriteBlock writes several records to a table.
DbiAppendRecord writes one reocrd to a table.

Both have to be filled with DbiPutField. (See also BDE help)


0
 
LVL 5

Author Comment

by:ronit051397
ID: 1358117
Thanks.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1358118
My pleasure. Hope you can go further on.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question