📄 writebuf2db.pas
字号:
unit WriteBuf2DB;
interface
uses SysUtils,Windows,Classes,DBClient;
type
TAppExitDoer=class
private
cdsDataSet:TClientDataSet;
tmprptSQLStr:string;
tmprptRecCnt:Cardinal;
function FormatTmpRptInsert(SeqNum: Cardinal; SubSPID: string;
SubmitSeqNum: Cardinal; MsgID, HandPhone:string;State: byte):string;
public
constructor create(DataSet:TClientDataSet);
procedure tmprptSubmit;
procedure tmprptAddSQLStr(SeqNum:Cardinal;SubSPID:string;SubmitSeqNum: Cardinal;MsgID,HandPhone:string;State:byte);
end;
implementation
{ TAppExitDoer }
constructor TAppExitDoer.create(DataSet: TClientDataSet);
begin
tmprptRecCnt:=0;
cdsDataSet:=DataSet;
end;
function TAppExitDoer.FormatTmpRptInsert(SeqNum: Cardinal; SubSPID: string;
SubmitSeqNum: Cardinal; MsgID, HandPhone:string;State: byte): string;
begin
Result:=Format('INSERT INTO SM_tmpReport(SequenceNum,SubSPID,SubmitSequenceNum,MsgID,HandPhone,State) VALUES(%d,''%s'',%d,''%s'',''%s'',%d)',
[SeqNum,SubSPID,SubmitSeqNum,MsgID,HandPhone,State]);
end;
procedure TAppExitDoer.tmprptAddSQLStr(SeqNum: Cardinal; SubSPID: string;
SubmitSeqNum: Cardinal; MsgID, HandPhone:string;State: byte);
var
tmpStr:string;
begin
tmpStr:=FormatTmpRptInsert(SeqNum,SubSPID,SubmitSeqNum,MsgID,HandPhone,
State);
if tmprptSQLStr<>'' then
tmprptSQLStr:=tmprptSQLStr+';'+tmpStr
else tmprptSQLStr:=tmpStr;
inc(tmprptRecCnt);
if tmprptRecCnt>=50 then
tmprptSubmit;
end;
procedure TAppExitDoer.tmprptSubmit;
begin
try
try
if tmprptRecCnt>0 then
with cdsDataSet do
begin
Close;
CommandText:=tmprptSQLStr;
Execute;
Close;
end;
except
on e:exception do ;
end;
finally
tmprptSQLStr:='';
tmprptRecCnt:=0;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -