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?

Background:

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)
from "SCHEMA"."TABLE"
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 comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 20 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.

    Regards,
    Florian

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

    Add comment
    10|10000 characters needed characters exceeded