Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: Looping over a table variable

$
0
0

Hi Daniel,

 

See update_product_prices.hdbprocedure in the package epmNext if you have access to SPS07, I have included the procedure code below.

 

Also see page 67 of the SPS07 SQL Script reference, and:

 

Iteration over SQL result in SQLScript procedure has an error

 

 

 

 

PROCEDURE "SAP_HANA_EPM_NEXT"."sap.hana.democontent.epmNext.procedures::update_product_prices" (

           in im_rate decimal(15,2),

           in im_direction nvarchar(10) DEFAULT 'INCREASE',

           out ex_products "SAP_HANA_EPM_NEXT"."sap.hana.democontent.epmNext.data::EPM.MasterData.Products"  )

  LANGUAGE SQLSCRIPT

  SQL SECURITY INVOKER

  --DEFAULT SCHEMA <default_schema_name>

  AS

BEGIN

/*****************************

  Write your procedure logic

*****************************/

declare v_new_price decimal(15,2);

declare CURSOR c_products FOR

    SELECT PRODUCTID, CATEGORY, PRICE from "SAP_HANA_EPM_NEXT"."sap.hana.democontent.epmNext.data::EPM.MasterData.Products";

 

 

FOR cur_row as c_products DO

 

  if :im_direction = 'INCREASE' then

    v_new_price := cur_row.PRICE + (cur_row.PRICE * :im_rate);

  elseif :im_direction = 'DECREASE' then

    v_new_price := cur_row.PRICE - (cur_row.PRICE * :im_rate);

  end if;

  UPDATE "SAP_HANA_EPM_NEXT"."sap.hana.democontent.epmNext.data::EPM.MasterData.Products"

        SET PRICE = V_new_price where PRODUCTID = cur_row.PRODUCTID;

 

END FOR;

 

 

ex_products = select * from "SAP_HANA_EPM_NEXT"."sap.hana.democontent.epmNext.data::EPM.MasterData.Products" ;

 

END;


Viewing all articles
Browse latest Browse all 9165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>