Re: Ado SQL Concept question.

From: Richard Speiss (rspeiss_at_mtxinc.com)
Date: 03/04/04

  • Next message: Jim Fleming: "Re: ADOCommand Text Editor Access Violation"
    Date: Thu, 4 Mar 2004 11:52:34 -0700
    
    

    Hi Rick,

    Here is something you can do that will speed up your lookups

    At the beginning of your routine, create a query that returns those values
    for all rows in the lookup table

    qryLookup.Close;
    qryLookup.SQL.Clear;
    qryLookup.SQL.Append('SELECT W, TI, WV, WH FROM PointInformation ORDER BY
    W');
    qryLookup.Open;

    for iIdx := 1 to LotsOfRecords do begin
      // Instead of opening the lookup query, now you just use Locate
      if qryLookup.Locate('W', sCLLI, []) = True then begin
        // do some processing here
      end
    end

    qryLookup.Close

    The slow part of using SQL is the act of opening the query. This will cause
    your program to slow down to a crawl if you are doing it for every record.

    The downside to the above method is that the lookup list is fixed for the
    duration of your loop. If you can live with that then you should be okay

    I hope this helps

    Richard Speiss

    "RPM" <rick@tariffnet.com> wrote in message
    news:404512a0$1@newsgroups.borland.com...
    > Hi everybody,
    >
    > I am an 'old dBase' programmer, been using Apollo since Delphi 1. Well I
    > have finally started writting some programs using ADO and Access/MSDE
    > (debugging on Access 97). I have learned alot about SQL and seem to be
    able
    > to get my queries to work. However I have a question about the overall
    > process.
    >
    > I need to do single record lookups - thousands of times - now my SELECT
    > statement works great and only returns the fields that my program
    requires.
    > So I have tried to keep it simple. However it is just increadibly SLOW,
    > when compared to the old dBase index file seeks. Is there anyway to
    > optimize this query?
    >
    > Here is my "seek" routine. (Using KAADO VCL tools for D5 Pro):
    >
    > Please note: The ADO connection remains open for the entire time. The file
    > only contains about 250,000 records. And is on my local machine (during
    > testing).
    >
    > function Tform1.AdoSeek( sCLLI: string ): boolean;
    > var
    > lResult: boolean;
    > begin
    > lResult := false;
    > AdoTable.Active := false;
    > with AdoTable.SQL do begin
    > Clear;
    > Add('SELECT W, TI, WV, WH');
    > Add('FROM PointInformation');
    > Add('WHERE W="'+sCLLI+'"');
    > end;
    > AdoTable.Active := true;
    > if AdoTable.Reccount > 0 then lResult := true;
    > AdoSeek := lResult;
    > end;
    >
    > Thanks in advance,
    > Rick
    >
    >


  • Next message: Jim Fleming: "Re: ADOCommand Text Editor Access Violation"

    Relevant Pages

    • Re: Basic Question for Lookups.
      ... However, especially in the early phases of setting up your Tables, you will probably need at times to look at their contents, and if so, you probably will want to define lookup properties on the foreign keys. ... The Query that I would suggest is similar to what the Lookup Wizard defines, except that I give mine a name, and I limit it to 2 fields instead of several. ... 1801550689 Michael Zachary Jackson ... I'm properly storing Prospect ID pk then FirstName then Middle then Lastname fields.etc. ...
      (microsoft.public.access.tablesdbdesign)
    • Re: Tip: Table design and query for bracketed lookup
      ... WHERE [Enter Bracket:] ... No rows would be returned by the query! ... If the "lookup" value is in a column of your query called Lookup, ... FROM RateTable RT1 ...
      (microsoft.public.access.queries)
    • Re: WHERE statement
      ... with basically all the info going to one table, except now the suppliers, ... "Jeff Boyce" wrote: ... and you can still use a combobox to list the lookup values. ... I know I get the ID field if I query against a 'lookup' ...
      (microsoft.public.access.gettingstarted)
    • Re: Understanding what makes Access tick
      ... > Query, but which is the subject of a table's lookup relationship. ... allow any "main" record..and "maybe" a child record. ... want here is a simply list of tasknumbers. ...
      (microsoft.public.access.gettingstarted)
    • Re: WHERE statement
      ... "Jeff Boyce" wrote: ... You can change the table's field from a lookup type to a (?whatever the ... I know I get the ID field if I query against a 'lookup' value. ... NOT USE Lookup data type fields, for just that reasons. ...
      (microsoft.public.access.gettingstarted)