1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Lookup Fails When Casting Id To An Integer.

Discussion in 'WebSpeed' started by GirdUpYourLoins, Aug 12, 2017 at 3:22 PM.

  1. GirdUpYourLoins

    GirdUpYourLoins New Member

    I have the following code which is supposed to for each through a database table and retrieve records based on id:

    FOR EACH Proj_Mstr WHERE Proj_Mstr.Proj_client_ID = INTEGER(get-value("clientId")) AND
    Proj_Mstr.Proj_deleted = ? NO-LOCK BREAK BY Proj_Mstr.Proj_sort:

    jObj:add(STRING(projNumber), Proj_Mstr.Proj_name).
    projNumber = projNumber + 1.
    END. /* admin 4ea */

    There are records that match the criteria, but no records are returned. If I change the variable in the search criteria to a literal, all appropriate records are returned:

    FOR EACH Proj_Mstr WHERE Proj_Mstr.Proj_client_ID = 1 AND
    Proj_Mstr.Proj_deleted = ? NO-LOCK BREAK BY Proj_Mstr.Proj_sort:

    jObj:add(STRING(projNumber), Proj_Mstr.Proj_name).
    projNumber = projNumber + 1.
    END. /* admin 4ea */

    When I test to see if INTEGER(get-value("clientId")) = 1, the return value is true. Why does casting the string to an integer cause the lookup to fail?
     
  2.  
  3. GirdUpYourLoins

    GirdUpYourLoins New Member

    How silly. Assigning the html parameter to a variable first fixed the problem.

    clientId = get-value("clientId").

    FOR EACH Proj_Mstr WHERE Proj_Mstr.Proj_client_ID = INTEGER(clientId) AND
    Proj_Mstr.Proj_name <> "Regular / Salary" AND
    Proj_Mstr.Proj_deleted = ? NO-LOCK BREAK BY Proj_Mstr.Proj_sort:

    jObj:add(STRING(projNumber), Proj_Mstr.Proj_name).
    projNumber = projNumber + 1.
    END. /* admin 4ea */
     
  4. Cringer

    Cringer ProgressTalk.com Moderator Staff Member

    Your query will most likely be more efficient with the second example anyway.
     
  5. Marco Mendoza

    Marco Mendoza Member

    get-value is an user-defined function. As is pointed on this article, the results can be unpredictable Progress KB - User Defined Functions (UDF) in WHERE clauses (FIND , CAN-FIND or FOR EACH) can be unpredictable
     

Share This Page