Skip to Content

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 .


Call Procedure A()


VAR_TAB = select customer_id from table_A;

EXEC ' select * from'||: var_tab;


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



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

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.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.