Sql 取分页数据:
vPage := 1;
PAGE_SIZE := 1000;
vFinished := false;
//按分页遍历取出已核销的数据进行校对
while not vFinished do
begin
//获得核销数据
vSql := ' SELECT TOP ' + IntToStr(PAGE_SIZE) + ' v.F_PjBm, v.F_Zch, v.F_Qsh, v.F_Zzh ' +
' FROM ' +
' (SELECT m1.F_Obj + m1.F_Dh + CAST(m1.F_Sxh AS VARCHAR) AS F_Id, m1.F_PjBm, m1.F_Zch, m1.F_Qsh, m1.F_Zzh ' +
' FROM ' + TableName('PX_HX_PjMX') + ' m1 ' +
' WHERE m1.F_PjBm <> '''' AND m1.F_Obj + m1.F_Dh + CAST(m1.F_Sxh AS VARCHAR) NOT IN ' +
' (SELECT TOP ' + IntToStr((vPage - 1) * PAGE_SIZE) + ' c.F_ID FROM ' +
' (SELECT m.F_Obj + m.F_Dh + CAST(m.F_Sxh AS VARCHAR) AS F_ID, m.F_PjBm, m.F_Zch, m.F_Qsh, m.F_Zzh ' +
' FROM ' + TableName('PX_HX_PjMX') + ' m ' +
' ) c ORDER BY c.F_PjBm, c.F_Zch, c.F_Qsh, c.F_Zzh) ' +
' ) v ' +
' ORDER BY v.F_PjBm, v.F_Zch, v.F_Qsh, v.F_Zzh ';
SR_Data.Open(ConnectDB, vSql);
vCR_KC.Data := SR_Data.data;
//合并已核销票据
MergeBill(vCR_KC,'Px_Qt_Xml_MergeMain','已核销');
if SR_Data.RecordCount < PAGE_SIZE then
vFinished := true;
//整合结存,并获得结存后的数据集
// CollCR_PJJC(vCR_QC,vCR_KC);
Inc(vPage);
end;