TStream实现多表查询
TStream实现多表查询
function TynFiredac.QuerySQLS(const ASQL, ASQL2: string; AStorageFormat: string = 'binary'): TStream; var LStream1, LStream2: TStream; begin Result := nil; if ASQL = '' then Exit; Result := TMemoryStream.Create; LStream1 := TMemoryStream.Create; LStream2 := TMemoryStream.Create; try try FDQuery1.Close; FDQuery1.SQL.Clear; FDQuery1.SQL.Add(ASQL); FDQuery1.Open; FDQuery1.SaveToStream(LStream1, TynStream.GetFDStorageFormat(AStorageFormat)); LStream1.Position := 0; FDQuery1.Close; FDQuery1.SQL.Clear; FDQuery1.SQL.Add(ASQL2); FDQuery1.Open; FDQuery1.SaveToStream(LStream2, TynStream.GetFDStorageFormat(AStorageFormat)); LStream2.Position := 0; TynStream.MergeStream(Result, LStream1, LStream2); except on E: Exception do begin Result := nil; Log.WriteLog('TynFiredac.QuerySQLs ' + E.Message); end; end; finally FDQuery1.Close; FDConnection1.Close; LStream1.Free; LStream2.Free; end; end;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/9947636.html