Board index » delphi » D2: Locate won't work on multiple columns

D2: Locate won't work on multiple columns

Fellow Delphi users:

I am trying to use the Locate statement on multiple columns, and it always
returns "false".  But it works on one column at a time.  I am using
Delphi 2.0 Developer, with an Oracle 7.0 database.  Am I doing something
wrong, or is this a real bug?

The code that works:

if meditNSN.text <> '' then
  begin
    strKeyFields := 'master_nsn_dodac';
    strKeyValues := meditNSN.text;
  end
else if ednomen.text <> '' then
  begin
    strKeyFields := 'master_nomen';
    strKeyValues := ednomen.text;
  end
else
  begin
    strKeyFields := 'master_mipr_no';
    strKeyValues := meditMipr.text;
  end;

if tableSDAFMast.locate (strKeyFields, strKeyValues, {}
   [loPartialKey]) then
  getprontot
else
  showmessage ('Not found');
end;

The code that doesn't work:

if tableSDAFMast.locate
    ('master_mipr_no;master_nsn_dodac;master_nomen', {}
     varArrayOf ([meditMipr.text, meditNSN.text, edNomen.text]), {}
    [loPartialKey]) then
  getprontot
else
  showmessage ('Not found');
end;

This always results in 'Not found'.

TIA.

Suzanne Sarlette

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

 

Re:D2: Locate won't work on multiple columns


Re:D2: Locate won't work on multiple columns


Check to see if all those fields are indexed.  I believe that LOCATE works
for INDEXED fields only even though Borland states the following in the
help file...

<begin quote>
Locate uses the fastest possible method to locate a matching record; if the
dataset has an index on the specified fields that's compatible with
case-insensitive matching (if you specify that in Options), the index will
be used. Otherwise, Locate sets up a Borland Database Engine filter for
efficient searching.
<end quote>

I have used multiple fields with a locate statement before and never had
problems when those fields were indexed, however I have encountered similar
problems as you have when one or more of those fields were not indexed.

ssarl...@ria-emh2.army.mil wrote in article
<872111568.19...@dejanews.com>...

Quote
> Fellow Delphi users:

> I am trying to use the Locate statement on multiple columns, and it
always
> returns "false".  But it works on one column at a time.  I am using
> Delphi 2.0 Developer, with an Oracle 7.0 database.  Am I doing something
> wrong, or is this a real bug?

Other Threads