odata服务忽略sql视图中的排序定义(SAP HANA Cloud Platform)

时间:2022-02-12 16:52:03

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.

学习SAP HANA的第一步是使用与数据库表和数据库视图相关的odata服务。我创建了XS项目,然后创建了一个数据库表,用内容填充它,然后创建了sql视图并定义了简单的odata服务topowners.xsodata。 sql视图已分组并排序。如果我调用(在Eclispe或WebIDE中)sql视图“显示内容”,则按定义的属性对条目进行正确排序。

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

如果在XS服务(在浏览器中)调用odata服务,则条目不按定义的属性排序。我该如何解决这个问题?谢谢


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

1 个解决方案

#1


0  

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

您可以通过在oData请求中添加$ orderby来解决问题:

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

See here for example

见这里的例子

#1


0  

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

您可以通过在oData请求中添加$ orderby来解决问题:

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

See here for example

见这里的例子