Quantcast
Channel: SCN: Message List - ABAP for SAP HANA
Viewing all articles
Browse latest Browse all 2110

Re: How to use dynamic colums with conditions into SELECT statment in AMDP?

$
0
0

Dynamic specification of column names (and table names) is a feature one is used to when coding ABAP OpenSQL but it is not a feature of HANA SQL-Script.

Note that AMDPs are simply database procedures stored in ABAP methods. Consequently, AMDP simply reflect HANA capabilities.

There is some kind of dynamic SQL in HANA using 'EXEC'-statement and string-manipulation, e.g.:

 

 

 

METHOD amdp_modify

  BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT

  USING tadir.

 

 

  declare column_name string := 'OBJECT';

 

 

  select "OBJECT" from tadir;

 

 

  EXEC( 'select "' || :column_name || '" from tadir' );

 

 

ENDMETHOD.

 

 

 

But then your AMDP can no longer have the READ-ONLY option and it is also difficult to access the result set of the EXEC-statement (when a 'select' is contained in its argument).

In the example above you would probably prefer to do your string-manipulation in ABAP and then use ADBC (http://scn.sap.com/message/16171819).

Dynamic ABAP Open-SQL is just a built-in feature of this string-manipulation (with a limited set of capabilities).


Viewing all articles
Browse latest Browse all 2110

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>