Skip to Content
0

Array_Concat in SAP HANA

Aug 30, 2017 at 08:31 AM

29

avatar image

Hi friends,

Here i try to perform Array concat the code whih is used as shown below:

--CONCATENATE TWO ARRAYS

CREATEPROCEDURE"keerthi"."ARRAY_COMPLEX_CONCAT3"
(OUT OUTTAB TABLE (SEQ INT,ID INT)) 
LANGUAGE SQLSCRIPT AS BEGIN
DECLARE id1,id2,id3,id4 , id5 INTEGER ARRAY;
id1[1]  := 1;
id1[2]:=2; 
id2[1]  := 1;  
id2[2]:=4;  
id3 := CONCAT(:id1, :id2);  
id4 := :id1 || :id2;  
rst = UNNEST(:id3) WITH ORDINALITY AS ("ID","SEQ");  
id5 := :id4 || ARRAY_AGG(:rst."ID"ORDERBY"SEQ");
outtab = SELECT SEQ,ID FROM :rst ORDERBY "SEQ";
END;

the procedure is executed successfully but the result is not what i expected:

| Seq |  Id |
--------------
|  1  |  1  |
|  2  |  2  |
|  3  |  1  |
|  4  |  4  |

Result what i expected is:

| Seq |  Id |
--------------
|  1  |  1,2 |
|  2  |  1,4 |
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers