Hi Vijeesh,
EXEC cant be used that way. On HANA you'd need to have one EXEC per statement. Each EXEC is a contained block of execution, allowing one statement only. Declaring variables is also not possible as far as I could see (anyone else please correct me if I'm wrong here).
For that reason I don't think you can use dynamic calculation expressions within EXEC / EXECUTE IMMEDIATE. I believe this is feature is not there yet.
Check the example below:
DO BEGIN DECLARE FORMULA NVARCHAR(5000) = ''; DECLARE VAL1 DECIMAL(19,2) = 10.0; DECLARE VAL2 DECIMAL(19,2) = 30.0; SELECT '(:VAL1 + :VAL2)' INTO FORMULA FROM DUMMY; EXECUTE IMMEDIATE 'SELECT '|| :FORMULA || ' FROM DUMMY'; END;
This would fail with:
"[...] cannot use parameter variable: VAL1:[...]"
BRs,
Lucas de Oliveira