Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  Orderby request oslc

    Posted Thu February 23, 2023 11:29 AM

    Hello,

    I have a problem, we use postman for API and I have a problem with the orderby. When we want orderby a description for example the orderby did the separation between upper and lower case.

    So when i order by i have something like this :

    • AAAAA2
    • ZZZZZ3
    • aaaa2

    I would like to know if someone know a solution to avoid my problem.

    Thanks you.



    ------------------------------
    Yann Bordelanne
    ------------------------------

    #Maximo
    #AssetandFacilitiesManagement


  • 2.  RE: Orderby request oslc

    Posted Fri February 24, 2023 04:20 AM

    Hi Yann,

    It seems like a database collation setting. Please check the link below:

    https://www.ibm.com/docs/en/mam/7.6.0.5?topic=begin-microsoft-sql-server-preparation

    If you are not able to change those settings, maybe you can use oslc where clause or regular query definitions to apply a where clause with "order by lower(description)" instead of orderby parameter.



    ------------------------------
    YALCIN KUMBASAR
    ------------------------------



  • 3.  RE: Orderby request oslc

    Posted Fri February 24, 2023 08:03 AM

    Aside from SQL Server (where our default supported configuration is case insensitive), this is expected behavior. We pass the order by to the database server and that's how it gets returned from the database. Each character has a different value, including lowercase and uppercase letters. If you had access to write the order by you could use a function to get the uppercase value but that is problematic from an indexing perspective (when you use functions like that, indexes on that column can't be used) and you can't control that in the REST API without having it as part of your saved query (at which point you cannot have an order by in the REST API or it would fail). 

    I would do this sort client side instead if you need to convert the values to uppercase and sort. 



    ------------------------------
    Steven Shull
    ------------------------------



  • 4.  RE: Orderby request oslc

    Posted Mon February 27, 2023 05:45 AM

    We have a Oracle SQL Database and when we use SQL, the orderby works as expected. We don't understand why the REST API give us an other orderby.



    ------------------------------
    Yann Bordelanne
    ------------------------------



  • 5.  RE: Orderby request oslc

    Posted Tue February 28, 2023 08:54 AM

    I would verify you're comparing apples to apples here. There are ways when writing a query where you could do something like:

    order by upper(colname)

    or you could be using linguistic sort like:

    order by nlssort(colname, 'NLS_SORT=GENERIC_M')


    But in general, an order by in Oracle is going to result with the lowercase at the bottom. Here's my order by on description in an Oracle system. 12461 is lowercase and is after all the other descriptions where the first letter was uppercase. 

    Now if I cast this to upper as part of the order by, then it works as you want.

     

    But the problem is the REST API doesn't provide that mechanism to wrap it in an upper() to do the order by. If you want something like that you need to open an idea here: https://ibm-ai-apps.ideas.ibm.com/ideas/



    ------------------------------
    Steven Shull
    ------------------------------