Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.419 Beiträge
 
Delphi 7 Professional
 
#5

AW: FB: Prepared Query mit In-Statement ?

  Alt 30. Dez 2017, 16:53
Jain, so absolut stimmt das nicht.

Je Parameter darf nur ein Wert übergeben werden.

Dashier funktioniert:
Delphi-Quellcode:
  qry.Close;
  qry.SQL.Clear;
  qry.SQL.Add('select feld3 from tabelle where feld1 = :feld1 ');
  qry.SQL.Add('and feld2 in (:feld2) ');
  qry.Prepare;
  qry.Params[0].AsInteger := 1;
  qry.Params[1].AsString := '''Feldinhalt''';
  qry.Open;
  ShowMessage(Format('%d',[qry.RecordCount]));
  qry.Close;
Dashier funktioniert ebenfalls:
Delphi-Quellcode:
  qry.Close;
  qry.SQL.Clear;
  qry.SQL.Add('select feld3 from tabelle where feld1 = :feld1 ');
  qry.SQL.Add('and feld2 in (:feld2a,:feld2b,:feld2c) ');
  qry.Prepare;
  qry.Params[0].AsInteger := 1;
  qry.Params[1].AsString := '''FeldinhaltA''';
  qry.Params[2].AsString := '''FeldinhaltB''';
  qry.Params[3].AsString := '''FeldinhaltC''';
  qry.Open;
  ShowMessage(Format('%d',[qry.RecordCount]));
  qry.Close;
Dashier funktioniert jedoch nicht:
Delphi-Quellcode:
  qry.Close;
  qry.SQL.Clear;
  qry.SQL.Add('select feld3 from tabelle where feld1 = :feld1 ');
  qry.SQL.Add('and feld2 in (:feld2) ');
  qry.Prepare;
  qry.Params[0].AsInteger := 1;
  qry.Params[1].AsString := '''FeldinhaltA'',''FeldinhaltB'',''FeldinhaltC''';
  qry.Open;
  ShowMessage(Format('%d',[qry.RecordCount]));
  qry.Close;
  Mit Zitat antworten Zitat