I have been trying to solve a requirement with no luck where I have to pass a table containing 3 fields: object name, customer & location from an AMDP to a stored procedure. The stored procedure should be used to return a table that stores the same customer, location & a min(date).
The min(date) is found in a table which is derived from the object name as follows: the concatenation of '"/BIC/A' || (object name passed from AMDP) || 2"'
. So, let's say if the AMDP passes the parameter object as YCUSTM01
, then the table name to look for the minimum date should be "/BIC/AYCUSTM012"
. Thus I should be able to make an execute_immediate statement (maybe?) to find what is the minimum date for a customer on a specific location & return that table back to the AMDP for further calculations.
Input Table:
| Object_name | Customer | Location |
+-------------+----------+----------+
| YCUSTM01 | Walgreen | Chicago |
Sample Data in "/BIC/AYCUSTM012"
:
| Customer | Location | Date |
+----------+----------+------------+
| Walgreen | Chicago | 24.09.2020 |
| Walgreen | Chicago | 07.02.2019 |
| Walgreen | Chicago | 12.12.2012 |
| Walgreen | Chicago | 01.04.2015 |
Desired Output Table from stored procedure :
select
customer,
location,
min(calday)
from "/BIC/AYCUSTM012"
where customer = :customer
and location = :location
group by
customer,
location;
| Customer | Location | Min_date |
+----------+----------+------------+
| Walgreen | Chicago | 12.12.2012 |
Any lead would be very much appreciated.