Alpha Video Training
Results 1 to 6 of 6

Thread: <table>.fetch_find()

  1. #1
    Member
    Real Name
    Garry M Flanigan
    Join Date
    Jul 2004
    Location
    Melbourne, Australia
    Posts
    909

    Default <table>.fetch_find()

    I read in the documentation regarding <table>.fetchfind() as follows:

    If <TBL>.FETCH_FIND() is successful, the found record is retrieved and its Record_Number is returned. If no exact match is found, a negative number corresponding to the record number of the closest matching record is returned.

    However, for example, I have found that a search "abcd" will report a +ve record number pointing to record "abc" where no "abcd" exists as the field and index is only 3 characters long. I would have expected a negative number for "abcd" as it is not an exact match. Obviously the extraneous characters are ignored.

    Version is 4130_3033.
    Last edited by Garry Flanigan; 12-01-2006 at 03:31 AM. Reason: realised problem - search string longer than index

  2. #2
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,143

    Default Re: <table>.fetch_find()

    Quote Originally Posted by Garry Flanigan View Post
    .... I have found that a search for say "abc" and "abcd" will find the same record where the value is actually "abc" and no "abcd" exists. I would have expected a negative number for "abcd" as it is not an exact match. This seems like a bug to me or have I missed something?

    Version is 4130_3033.

    PS. Fortunately, the lookup function does only find the correct exact match, so I will use this instead.
    I do not think this is a bug. It is just that in the context where <TBL>.FETCH_FIND() is typically used, "abcd" is an "exact match" for "abc" as the former "exactly" (!!!) contains the latter. Maybe the wording in the documentation is a bit misleading but this is the way <TBL>.FETCH_FIND() should work. As you noted, there are other methods to do other things in other contexts.

    Ray

  3. #3
    Member
    Real Name
    Garry M Flanigan
    Join Date
    Jul 2004
    Location
    Melbourne, Australia
    Posts
    909

    Default Re: <table>.fetch_find()

    Ray,

    You were very quick with a reply!!

    Note that I did some more research and altered my original post. It relates to extraneous characters being ignored. However, I would not call such a match an exact match and consider the documentation to be misleading.

  4. #4
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: <table>.fetch_find()

    Garry, I don't recall bumping into this situation before and can see why the result surprised you. Suggest you submit a bug report and use it to suggest specific change to the documentation.

  5. #5
    Former Alpha Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,172

    Default Re: <table>.fetch_find()

    The documentation may be slightly misleading, but it is correct.

    "Alpha Five will automatically pad the Matching_Expression with trailing blanks if necessary so that the length of Matching_Expression matches the index key length." (bold added for emphasis).

    While it isn't normal to enter an expression that is longer than the field length, the help text indicates that the expression length will be altered to match the field length. Therefore, if the field is only 3 characters, and there is a record with a value of "abc" , searching for "abcd" will have a match, as the expression "abcd" will be truncated to match the field length of 3.

    If it is expected that some search expressions may be longer that the field length, there are a couple options. The best is to limit the expression length to the field length. Since the use of fetch_find() indicates it is being used in a script, it would be easy to check the length of any entered expression using len() and output a message to the user to tell them the expression entered is too long.

    The second is to make the field longer, even if only 3 (in this example) characters are used. The fetch will add blanks to the actual field lenght.

  6. #6
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: <table>.fetch_find()

    Jerry, good morning.

    I agree the documentation is correct, but it's correct only as far as it goes. While addressing the behavior of the method if the Matching_Expression is shorter than the index key length, it does not address the behavior of the method if the Matching_Expression is longer than the index key length. Since subtleties are lost on me (according to my wife), an explicit description of the behavior would improve the documentation... at least for me.

Similar Threads

  1. fetch_find()
    By dik_coleman in forum Alpha Five Version 7
    Replies: 5
    Last Post: 03-25-2006, 05:57 AM
  2. tbl.fetch_find()
    By Zod Mansour in forum Alpha Five Version 6
    Replies: 2
    Last Post: 11-01-2004, 08:10 AM
  3. tbl.fetch_find()
    By Zod Mansour in forum Alpha Five Version 6
    Replies: 3
    Last Post: 10-20-2004, 01:24 PM
  4. fetch_find
    By geoff m in forum Alpha Five Version 5
    Replies: 6
    Last Post: 05-27-2004, 08:04 AM
  5. fetch_find()
    By martinwcole in forum Alpha Five Version 4
    Replies: 7
    Last Post: 09-12-2000, 05:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •