Skip to Content
-1

How to use table variable in dynamic sql

Hi ,

Inside a procedure, I use a table variable to store the some result from table A .

I have to use this table variable in dynamic sql .

Eg)

Call Procedure A()

Begin

VAR_TAB = select customer_id from table_A;

EXEC ' select * from'||: var_tab;

End;

The above code will throw error. Anyone has a solution for this ?

Thanks,

Yogesh

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Posted on Mar 13, 2016 at 06:55 PM

    Hello Yogesh,

    as mentioned in the SQLScript Reference (Dynamic SQL - SAP HANA SQLScript Reference - SAP Library) it is not possible to address SQLScript variables in a dynamic SQL statement. If really necessary you could exchange information between the SQLScript and the dynamic SQL via local temporary tables. But of course you should avoid dynamic SQL if possible due to the big disadvantages.

    Regards,

    Florian

    Add comment
    10|10000 characters needed characters exceeded