Hello Colleague,
I had a requirement where I have to join multiple tables and the where condition should be dynamic.
I was trying to create a stored procedure in HANA using AMDP. HANA provides APPLY_FILTER to pass a dynamic where clause to previous selected data from a join of tables. The dynamic where clause may have fields from any of the 6 different tables used in the join. In such a case the column list of the select join should have all the columns from all the included tables. Even if I do that there can be columns with the same names in the different tables which is a problem.
Something like this.
BEGIN
- Select x y z - the column list is fixed and is only from one table
From a
Inner join b
Inner join c
Inner join d
Inner join e
Inner join f
Into it_tab
- Where :iv_where_clause -- this addition is not supported yet so have to use APPLY filter
- Filtered_data = APPLY_filter (:it_tab, :iv_where_clause)-- the where clause can have fields from different tables of the select
Further processing of data ….
END
Do you know any other way to directly pass this where clause in the select statement itself. The only other way I could think of is a complete dynamic select string (both the select and the where clause) using EXEC which fills a local temporary table and then and processes the local temporary table further.
Kindly give your inputs.
Thanks & Regards,
Rohit