Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

Increment Value in FOR Loop in sap hana

$
0
0

Hi All,

 

The default incremented value for FOR loop is 1 (shown in the below example). Is there any way to modify it?

 

In the below example, the value of i gets incremented by 1 each time, i would like to increment it by '2'  (or '3'). 

 

 

Create procedure forrr(IN inval INT, out val int)

as

i int :=0;

begin

Declare  a1 int default 0;

  For i in 1..inval DO

  a1:=a1+i;

  End For;

  Val:=a1;

end;

 

Call forrr(5,?)---> Output is: 15 (sum of digits from 1 to 5)

 

I tried with a statement i:=i+1; after   a1:=a1+i;  but it is throwing the below error:

 


Error: Could not execute 'Create procedure forrr(IN inval INT, out val int) as i int :=0; begin Declare a1 int default 0; For ...' in 446 ms 111 µs .

SAP DBTech JDBC: [1288] (at 135): expression cannot be used as an assignment target: I: line 8 col 3 (at pos 135)

 

I am looking forward for your inputs.

 

 

Thanks,

Sree


Viewing all articles
Browse latest Browse all 5653

Trending Articles



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