Page 1 of 1

I can not select my record (gbk charset mydac 5.80 )

Posted: Mon 06 Apr 2009 06:01
by vga
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;

Posted: Mon 06 Apr 2009 07:44
by Dimon
Please give a more detailed description of the problem that arises in you application.

Posted: Tue 07 Apr 2009 00:04
by vga
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.

Posted: Tue 07 Apr 2009 00:18
by vga
I'am sorry!

I got a ":" before %d and `typer1`=%s and `state1`=1 limit 1

It work fine!

thank you!

Posted: Tue 07 Apr 2009 07:54
by Dimon
It is good to see that this problem has been solved.