Skip to Content

SAP HANA Execute Immediate with [INTO ]

The Documentation for Execute Immediate unfortunately does not show how to use the into statement.

So how can i store the result of a dynamic SQL in a variable?


I need dynamic SQL since the table name and columns are variables like this:

dynSql := 'SELECT max(' || searchColName || ') ' || char(10);
dynSql := dynSql || 'FROM ' || tbl || char(10);
dynSql := dynSql || 'WHERE ' || whereColName || ' = ''' || whereColValue || '''';

execute immediate dynSql;-- into outputValue;

The variable content could be:

select max(TIMESTAMP)
where "UniqueId" = 'XXX123XX-EA9E-43F4-AB27-104B3E4DXXXX';

So how can i store the value of TIMESTAMP in the output variable of the stored proceedure?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Feb 20, 2018 at 10:03 AM

    I think the documentation is already quite clear regarding that (also not providing a code example). But you can check the blog here for an example.


    PS: I assume you have already a HANA 2.0 SPS01 system to have this feature supported.

    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.