on 07-21-2014 10:35 AM
Hello,
I need to calculate cumulative stocks. I want to do it using SAP HANA analysis process. I created test procedure with cursor and VAR_OUT inside cursor. When i call this procedure i always get only one value. How i can get more then one value from this procedure?
DECLARE CURSOR c_cursor1 FOR
Select "SUPNUM" FROM "_SYS_BIC"."Stocks/STOCKS"
WHERE "SUPNUM" IN ('00000028345', '00000039053')
GROUP BY "SUPNUM";
FOR cur_row as c_cursor1 DO
VAR_OUT = Select "SUPNUM" FROM "_SYS_BIC"."Stocks/STOCKS"
WHERE "SUPNUM" = cur_row.SUPNUM GROUP BY "SUPNUM";
END FOR
Hi Sergey,
If you want to retain the cursor(though you could try the same with JOINS), you can consider using arrays.
DECLARE CURSOR c_cursor1 FOR
SELECT "SUPNUM" FROM "_SYS_BIC"."Stocks/STOCKS"
WHERE "SUPNUM" IN ('00000028345', '00000039053')
GROUP BY "SUPNUM";
DECLARE AR_SUPNUM VARCHAR(10) ARRAY;
FOR cur_row as c_cursor1 DO
V_COUNT := V_COUNT + 1;
Select "SUPNUM" FROM "_SYS_BIC"."Stocks/STOCKS" INTO V_SUPNUM
WHERE "SUPNUM" = cur_row.SUPNUM GROUP BY "SUPNUM";
AR_SUPNUM[:V_COUNT] = :V_SUPNUM;
END FOR
VAR_OUT = UNNEST(:AR_SUPNUM)
Nehal.
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.