This app is an All-In-One package to provide everything to HANA Lovers.
1. Courses on SAP HANA - Basics, Modeling and Administration
2. Multiple Quizzes on Overview, Modelling, Architeture, and Administration
3. Most popular articles on SAP HANA
4. Series of Interview questions to brushup your HANA skills
In this article we will show an example of SAP HANA procedure to show – How to use For Loop.
The For loop iterates a range of numeric values. BREAK:
Specifies that a loop should stop being processed. CONTINUE:
Specifies that a loop should stop processing the current iteration, and should immediately start processing the next.
In this example we will define a loop sequence. If the loop value :x is less than 3 the iterations will be skipped. If :x is 5 then the loop will terminate.
Copy and paste the below script to create the procedure.
----REPLACE <SCHEMA_NAME> WITH YOUR SCHEMA NAME
CREATE PROCEDURE <SCHEMA_NAME>."FOR_LOOP_EXAMPLE"(
OUT output_var INT)
SQL SECURITY INVOKER
/*********BEGIN PROCEDURE SCRIPT ************/
DECLARE count INT := 0;
DECLARE v_index INT;
FOR v_index IN 0 .. 10 DO
IF :v_index < 3 THEN
ELSEIF :v_index = 5 THEN
count := count + 1;
output_var := count;