简体   繁体   中英

odata service ignores sorting definition in sql view (SAP HANA Cloud Platform)

My first step to learning SAP HANA was usage of odata services related to database tables and database views. I created the XS Project, then a database table, fill it with content and then created the sql view and definded simple odata service topowners.xsodata . The sql view was grouped and ordered. If i call (in Eclispe or WebIDE) the sql view "display content" , the entries are correct ordered by defined attribute.

If is call the odata service in XS Service (in browser) the entries are NOT ordered by defined attribute. How do I solve the problem? Thank you


odata Service definition

service { 
"DB_XS"."SUM_VIEW" as "TopOwners"
key  ("owner_code") 
    create forbidden
    update forbidden
    delete forbidden;
}

sql view definition

CREATE VIEW "DB_XS"."SUM_VIEW" ( "owner_code",
     "owner_count"
) AS select
     owners."owner_code" ,
     SUM("current_owner_cnt") as "owner_count"  

from "DB_XS"."owners" owners 

group by owners."owner_code"  

order by "owner_count" desc 
     p WITH READ ONLY

You can solve the problem by adding a $orderby in your oData request:

 http:// ... /topowners.xsodata/TopOwners?$orderby=owner_count

See here for example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM