Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAP HANA SQL Query with Dynamic Placeholder

Tags:

hana

I have a query that is passing the current year as a placeholder parameter that right now is hard coded. How can I have this just pass the current year? I've seen a few different potential solutions but most of them are in HANA Studio or involve dynamic SQL generation.

I'm putting the SQL into Tableau so those are both off the table.

...sum("StockInQualityInspection") as in_quality,
         sum("StockInTransit") as its
  from "_SYS_BIC"."stream.models.marketing.poly/InventoryQuery" ('PLACEHOLDER' = ('$$IPCurrentYear$$', '2018'))
  where "StockValuatedUnrestrictedUse" <> 0 or "StockInQualityInspection" <> 0 or "StockInTransit" <> 0
  group by case when "ReceivingPlant" is null then "Plant" else "ReceivingPlant" end, 
           case.... 
like image 548
Andrew Avatar asked Oct 19 '25 05:10

Andrew


1 Answers

  • Remove the parameters input of your CV
  • Add this expression: year(now())

If you don't have access to manipulate the CV, into your query use:

  • ('PLACEHOLDER' = ('$$IPCurrentYear$$', select year(now()) from DUMMY))

Regards

like image 162
Caio Melzer Avatar answered Oct 22 '25 05:10

Caio Melzer