SAP HANA SQL Query with Dynamic Placeholder

浪子不回头ぞ 提交于 2020-02-24 05:13:25

问题


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.... 

回答1:


  • 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



来源:https://stackoverflow.com/questions/49615710/sap-hana-sql-query-with-dynamic-placeholder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!