sap hana - select top expression

Inbal Suika Miller picture Inbal Suika Miller · Jan 11, 2017 · Viewed 8.5k times · Source

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.

Answer

Lars Br. picture Lars Br. · Jan 11, 2017

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