Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic SQL in AMDP/HANA

0 Likes
5,109

Hi all,

Is it possible to apply a dynamic where clause in AMDP like ABAP

ex:

SELECT c1 c2.. from T1

...

where(my_dynamic_where_clause) ?

I dint' get proper documentation on AMDP dynamic sql's

Query 2:-

I see that  there's EXEC 'sql_query' in stored procedures.we cannot use EXEC in read only procedures.

when i try to create a procedure , in the wizard it's always "read_only" procedure that is created., How to create a  read-write procedure?

Is it authorization issue ? If not what am i missing here?


Regards

Saurabh

3 REPLIES 3
Read only

0 Likes
1,957

Syntax of the method body of AMDP is SQL Script. You can see this mentioned in

Jens promises more details later "More details for AMDP will follow soon and can be found in a detailed document here in SCN ( ABAP Managed Database Procedures) " in his blog You can see a glimpse of what would be possible with respect to "read_only" in the picture there and in the video Introduction into ABAP Managed Database Procedures on SAP HANA.

Read only

0 Likes
1,957

A colleague pointed out to me that specifics of your question is not answered in the references I offered earlier. Let me try to rectify that.

Could you please check out APPLY_FILTER in the SAP HANA SQL Script reference. This might be what you are looking for. In this case you will not need to use "EXEC 'sql_string'. You can do the following instead:


temp_result = SELECT c1 c2.. from T1 ...;

result = APPLY_FILTER(:temp_result, :my_dynamic_where_clause)

Don't be afraid that temp_result will be fetched and later filtered. If you do not read temp_result only result will be fetched after applying the filter.


Hope this answers your query better.


Read only

1,957

The best practice is the opposite. First the filter is created and then the query

*...Filtro
    ex_it_vbak_filter = APPLY_FILTER (vbak,:ip_filter_vbeln_auart);

*...Select Data
    ex_it_vbak = SELECT vbeln,auart
                 FROM :ex_it_vbak_filter