My code:
(mydac 5.80 delphi 7.1)
procedure TForm1.con1AfterConnect(Sender: TObject);
begin
con1.ExecSQL('set names gbk', []);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
con1.Open;
end;
procedure TForm1.btn2Click(Sender: TObject);
var
i: Cardinal;
t: Cardinal;
begin
t := GetTickCount();
for i := 1 to 100000 do begin
con1.ExecSQL(format('insert into `state` (`Pic_Id`, `Block_ID`, `BATCH_ID`) values (%d, 1, 1)', ), []);
caption := IntToStr(i);
end;
Caption := FloatToStr((GetTickCount()-t)/1000);
end;
procedure TForm1.btn3Click(Sender: TObject);
var
curPicID: integer;
typer: string;
t: Cardinal;
begin
typer := '錦';
curPicID := 0;
t := GetTickCount;
repeat
Application.ProcessMessages;
myqry1.SQL.Text := Format('update `state` set `typer1`=''%s'', `state1`=1 where `pic_id`>=%d and `state1`=0 limit 1', [Typer, curPicID+1]);
myqry1.Execute;
myqry1.SQL.Text := Format('select `pic_id`,`pic_name` from `state` where `pic_id`>=:%d and `typer1`=''%s'' and `state1`=1 limit 1', [curPicID+1, typer]);
myqry1.Open;
if not myqry1.IsEmpty then begin
curPicID := myqry1.Fields[0].AsInteger;
caption := IntToStr(curPicID);
con1.ExecSQL(Format('update `state` set `state1`=2 where `pic_id`=%d', [curPicID]), []);
end else break;
until false;
Caption := FloatToStr((GetTickCount()-t)/1000);
end;
I can not select my record (gbk charset mydac 5.80 )
I insert record with:
con1.ExecSQL(format('insert into `state` (`Pic_Id`, `Block_ID`, `BATCH_ID`) values (%d, 1, 1)', ), []);
and update record with
myqry1.SQL.Text := Format('update `state` set `typer1`=%s, `state1`=1 where `pic_id`>=%d and `state1`=0 limit 1', [QuotedStr(Typer), curPicID+1]);
myqry1.Execute;
then I select record with
myqry1.SQL.Text := Format('select `pic_id`,`pic_name` from `state` where `pic_id`>=:%d and `typer1`=%s and `state1`=1 limit 1', [curPicID, QuotedStr(typer)]);
myqry1.Open;
but myqry1.IsEmpty is true.
con1.ExecSQL(format('insert into `state` (`Pic_Id`, `Block_ID`, `BATCH_ID`) values (%d, 1, 1)', ), []);
and update record with
myqry1.SQL.Text := Format('update `state` set `typer1`=%s, `state1`=1 where `pic_id`>=%d and `state1`=0 limit 1', [QuotedStr(Typer), curPicID+1]);
myqry1.Execute;
then I select record with
myqry1.SQL.Text := Format('select `pic_id`,`pic_name` from `state` where `pic_id`>=:%d and `typer1`=%s and `state1`=1 limit 1', [curPicID, QuotedStr(typer)]);
myqry1.Open;
but myqry1.IsEmpty is true.