Skip to Content

How to assign a variable to the result of a query in HANA?

Nov 02, 2016 at 11:24 AM


avatar image

Hello, all

How does one assign the result of a query to a scalar variable in HANA? In MS SQL I could:

SET @myvar = ( SELECT CardName FROM OCRD WHERE CardCode = @cc )

or, for several variables:

SELECT @var1 = Field1, @var2 = Field2 FROM MYTABLE WHERE Code = @code

The only way to do itin HANA that I have found is via a very long compass, i.e. by dint of a cursor. But cursors being intended for the iteration over several data rows, they are very clumsy in such simple an operation as a single assignment of a single scalar variable. I should say it is actually an abuse of cursor, so there ought to be a better way. Is there one?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers