Subject Re: Equivalent SQL to Dataset.Locate statement
Author mikcaau
--- In, "Nols Smit" <nols@...> wrote:
> Hi.
> In a FireBird 1.5 and Delphi 7 application, when the user transmit a
key value of a table, I use the Pascal DataSet.Locate statement:
> if not IBDRegister.Locate('Specimen_Nr', VarArrayOf([This_ID]),
[loPartialKey]) then
> ShowMessage('No such record!');
> But it seems very slow in execution. What will the equivalent SQL
Select statement be to locate a specific record but not to limit the
user to that record located. In other words: After execution of the
statement, the user must be able to move to previous and next record.
> Regards,
> Nols Smit
The query
Select Specimen_Nr
from SomeTable
where Specimen_Nr = :SpecNo

In Delphi := true;
If not prepared then prepare;
ParamByName('SpecNo').asString := "'%" + Param + "%'";

if not FieldByName('Specimen_Nr').IsNull then begin
ShowMessage('No such record!');
end else begin
ShowMessage('Record found!');

If Transaction.InTransaction then Transaction.Commit;