3

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.... 
Andrew
  • 31
  • 1
  • 2
  • `Select year(now()) from dummy` so just `year(now())` careful around edge cases such as time zone variances at year end/year beginning.. – xQbert Apr 06 '18 at 18:37

2 Answers2

2
  • 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

Caio Melzer
  • 130
  • 3
0

while placing a query is not permitted, you can pass a parameter as following

 do begin
  declare lv_param nvarchar(100);
  select max('some_date')
    into lv_param
  from dummy /*your_table*/;
  
  select *
  from "_SYS_BIC"."path.to.your.view/CV_TEST" (
    PLACEHOLDER."$$P_DUMMY$$" => :lv_param
  );
end;

more can be found here credit to @astentx

Manny
  • 87
  • 2
  • 14