Einzelnen Beitrag anzeigen

Amenovis

Registriert seit: 16. Nov 2011
52 Beiträge
 
#13

AW: DB 2Werte vergleichen um zwischen Insert und Update zu unterscheiden

  Alt 25. Nov 2018, 18:19
Sorry für Doppelposting aber hat vielleicht jemand eine Idee was ich jetzt wieder Falsch mache ?

Delphi-Quellcode:
RQuery2.SQL.Text:='SELECT count(*) as var2 FROM OPmonth where ID=:ID';
  RQuery2.ParamByName('ID').AsString := edit25.Text;
  RQuery2.Open;
  if RQuery2.FieldByName('var2').AsInteger > 0
  then begin
  id:=Edit15.Text;
  query1.Params.CreateParam(ftString,'id',ptinputoutput);
  query1.ParamByName('id').Text:=id;
  query1.SQL.Text:='select WorkH,EIndex,WIndex from OPmonth where id=:id';
  Query1.Open;
  Query1.Params.CreateParam(ftString,'WorkH',ptInputOutput);
  Query1.Params.CreateParam(ftString,'EIndex',ptInputOutput);
  Query1.Params.CreateParam(ftString,'WIndex',ptInputOutput);
  Query1.ParamByName('WorkH').Text:=Edit29.Text;
  Query1.ParamByName('EIndex').Text:=Edit64.Text;
  Query1.ParamByName('WIndex').Text:=Edit65.Text;
  Query1.SQL.Text:='update OPmonth set WorkH=:WorkH,EIndex=:EIndex,WIndex=:WIndex where id=:id';
  Query1.ExecSQL;
  end
  else
  query1.SQL.Text:='select WorkH,EIndex,WIndex from OPmonth where id=:id';
  Query1.Open;
  Query1.Params.CreateParam(ftString,'WorkH',ptInputOutput);
  Query1.Params.CreateParam(ftString,'EIndex',ptInputOutput);
  Query1.Params.CreateParam(ftString,'WIndex',ptInputOutput);
  Query1.ParamByName('WorkH').Text:=Edit29.Text;
  Query1.ParamByName('EIndex').Text:=Edit64.Text;
  Query1.ParamByName('WIndex').Text:=Edit65.Text;
  Query1.SQL.Text:='Insert into OPmonth (WorkH,EIndex,WIndex)'+
   'values (:WorkH,:EIndex,WIndex)';
  Query1.ExecSQL;
  end;
  Mit Zitat antworten Zitat