Einzelnen Beitrag anzeigen

sega84

Registriert seit: 18. Sep 2006
73 Beiträge
 
Delphi XE2 Professional
 
#9

AW: Prozedur (SQL-Statement) optimieren

  Alt 21. Feb 2011, 12:33
Hi, gebe allen anderen Recht... Habe allerdings noch ne Idee, wie du die verarbeitung besser machen könntest...

Delphi-Quellcode:
procedure Tdata.getCatalog(var ioList : TDocxDocument; inList : TStringList; language : integer=1);
var
  i : integer;
  tmp : TDocxline;
  flevel, farticle_id, fadditional_position : TField;
begin
  ioList.Clear;
  if workQuery.Active then WorkQuery.Active := false;
  workQuery.SQL.Clear;
  workQuery.SQL.Add('SELECT ass.level, ass.article_id, ass.additional_position, ass.mcount, ass.img, trans.name, art.number, art.type FROM ');
  workQuery.SQL.Add('assignments as ass JOIN articles as art ON ass.article_id=art.id JOIN translations as trans ON trans.article_id=art.id WHERE');
  workQuery.SQL.Add('trans.language_id=:lng AND ass.id=:id');
  for i := 0 to inlist.Count - 1 do
  begin
    workQuery.ParamByName('id').AsInteger := StrToInt(inList[i]);
    workQuery.ParamByName('lng').AsInteger := language;
    workQuery.Open;
    flevel := workQuery.Fields[0];
    farticle_id := workQuery.Fields[1];
    fadditional_position := workQuery.Fields[2];
    //....
    if not workQuery.IsEmpty then
    begin
      tmp.level := flevel.AsInteger;
      tmp.article_id := farticle_id.AsInteger;
      tmp.additional_position := fadditional_position.AsInteger;
      //....
      ioList.AddRange(tmp);
    end;
    workQuery.Close;
  end;
end;
  Mit Zitat antworten Zitat