Results 1 to 8 of 8

Thread: Can't seem to get keylookup to work

  1. #1
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657

    Can't seem to get keylookup to work

    I have two tables danimal and dtaxon

    Index key in dtaxon is called PRIMARY
    I want to return the common name from the dtaxon table when passed the foreigne key for it from danimal

    Using the following code in the console simply return .F. . What am I doing wrong here?

    open database aim
    use danimal in 0
    ? keylookup("dtaxon","PRIMARY",danimal.cfk_dtaxon,cc ommon,"not found")

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi David,

    KEYLOOKUP(<workarea> | <"alias"> | <"table">, <"indextagname">, <keyExpr>, <resultExpr> [, <notfoundExpr>])

    That should all work. Sorry my previous reply was incorrect. The table is opened if it isn't already open.


    Last edited by barrymavin; 2018-11-02 at 05:02.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657
    Hi Barry,

    In the documentation is only seems to be opeing one table
    open database southwind
    use orders in 0
    ? keylookup("employees","employeeid",orders.employee id, lastname, "not found")

    If I try

    open database aim
    use danimal in 0
    use dtaxon in 0
    ? keylookup("dtaxon","PRIMARY",danimal.cfk_dtaxon,cc ommon,"not found")

    It still returns .F.

    Maybe the name of the index being PRIMARY is an issue as maybe a keyword ?

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    No the index tag name is not a problem.

    Try seeking to danimal.cfk_dtaxon in dtaxon and inspecting it.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    It will return false if it cannot find the index tag.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657
    Display index for dtaxon is showing as blank for some reason. I imported the tables.

    Danimal index shows when I use display index.

    I'll play around and find out what there is no index on that table.

    Would it be possible for the system to create the index on the fly if it was not there ?

  7. #7
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657
    select dtaxon
    display index
    Show nothing

    create index dtaxon on dtaxon (ccommon)

    shows
    Production DBX file: dtaxon.dbx
    Master Index TAG: DTAXON
    Key: CCOMMON
    Type: Character
    Len: 158


    create index dtaxon on dtaxon (Primary)

    shows

    Fri Nov 2 14:38:42 2018
    **** Lianja error ****
    create index dtaxon on dtaxon (primary)
    ^
    Expression was expected

    So it looks as though I'll have to alter the primary key name in all my tables, this was imported from VPM

  8. #8
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657
    Works fine when I have the index there.

    Thanks Barry

Bookmarks

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
  •  
Journey into the Cloud
Join us