函数定义:
function DbiWriteBlock (hCursor: hDBICur; var iRecords: Longint; pBuf: Pointer): DBIResult stdcall;
说明:
DbiWriteBlock 将记录块写入与关联的表中
h光标。
参数:
hCursor Type: hDBICur (Input) Specifies the cursor handle to the table.
piRecords Type: pUINT32 (Input/Output) On input, piRecords is a pointer to the number of records to write. On output, pointer to the client variable that receives the actual number of records written. The number actually written may be less than requested if an integrity violation or other error occurred.
pBuf Type: pBYTE (Input) Pointer to the buffer containing the records to be written.
用法:
这个函数类似于为指定的调用 DbiAppendRecord
piRecords 的数量。 DbiWriteBlock 可以访问更大的块中的数据
大于 64Kb,具体取决于您为缓冲区分配的大小。
注意:
如果记录中包含非空 BLOB,则不能使用此函数。
悖论:
此功能验证任何参照完整性要求或
可能进行的有效性检查。如果任一失败,则写入
操作被取消。
完成状态:
光标位于最后插入的记录处。
结果:
DbiResult Meaning
DBIERR_NONE The block of records contained in pBuf has been successfully written to the table specified by hCursor.
DBIERR_INVALIDHNDL The specified cursor handle is invalid or NULL, or piRecords is NULL, or pBuf is NULL.
DBIERR_TABLEREADONLY The table is opened read-only; cannot write to it.
DBIERR_NOTSUFFTABLERIGHTS Insufficient table rights to insert a record. (Paradox only.)
DBIERR_NODISKSPACE Insertion failed due to insufficient disk space.
Delphi 7 帮助示例:
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('INPRISE Corporation')));
Inc(pTmpBuf, RecordSize);
end;
end;
Check(DbiWriteBLock(Customer.Handle, RecordsToInsert, pRecordsBuf));
finally
FreeMem(pRecordsBuf, Customer.RecordSize * RecordsToInsert);
end;
end