on 08-06-2013 2:20 PM
hi Friends,
Whats the FOR loop, what is situations where we use this.
regards
Hi Sushil,
Normally, you can use for loop in procedure or sql script base of calculation view , it is only loop syntax, such as below script.
CREATE PROCEDURE nested_block_for(IN inval INT, OUT val INT) LANGUAGE SQLSCRIPT
READS SQL DATA AS
BEGIN
DECLARE a1 int default 0;
DECLARE a2 int default 0;
DECLARE v1 int default 1;
DECLARE v2 int default 1;
DECLARE v3 int default 1;
DECLARE CURSOR C FOR SELECT * FROM mytab1;
FOR R as C DO
DECLARE CURSOR C FOR SELECT * FROM mytab2;
a1 := a1 + R.a;
FOR R as C DO DECLARE CURSOR C FOR SELECT * FROM mytab3;
a2 := a2 + R.a;
FOR R as C DO
a3 := a3 + R.a;
END FOR;
END FOR;
END FOR;
END;
You can reference SQL guide document.
http://help.sap.com/hana/SAP_HANA_SQL_Reference_en.pdf
Hope this can help you.
Regards,
Jerry
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.