sap hana - select top expression

删除回忆录丶 提交于 2020-01-04 04:54:11

问题


I have a problem with a stored procedure.

The procedure gets as an argument the number of rows needed, but the following does not work in HANA:

SELECT TOP :NUM_OF_ROWS * FROM TABLE_NAME

I read that TOP in HANA only receives a number, not an expression. Is there another way to do this? My solution for the moment is to select everything and delete the unneeded records on the service, but it's not very efficient.


回答1:


Instead of TOP n you can use the LIMIT n option. That one can bind variables.




回答2:


Can you tell in what system did you execute this query? To be honest I use HANA Studio with R interchangeably and I was able to execute and receive results using SELECT TOP 10 * FROM data.table




回答3:


I'm able to use top n with n as scalar variable. Which version of HANA is being used?

do begin 
declare i integer;
i := 1;
select top :i CURRENT_TIMESTAMP from dummy;
end;


来源:https://stackoverflow.com/questions/41592876/sap-hana-select-top-expression

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!