问题
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