Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

ARRAY_AGG function is not working with UNNEST function in SAP HANA SQL Procedure?

$
0
0

Hi,

 

Can anyone suggest me how to use ARRAY_AGG function with UNNEST combination to append rows of the SELECT Query on a Table which is written inside WHILE loop.

 

for example:

 

DECLARE CURSOR C_RESOURCES FOR

     SELECT MANDT, OBJID, STEXT from HRP1000

     where OTYPE = 'CP'

     and BEGDA <= TO_NVARCHAR(now(), 'YYYYMMDD')

     and ENDDA >= TO_NVARCHAR(now(), 'YYYYMMDD')

     and PLVAR  = '01';

 

FOR CUR_ROW as C_RESOURCES DO

 

     WHILE L_ENTRIES > 0 DO

    

          IT_HRP1001 =

          SELECT MANDT, OBJID, OTYPE, SCLAS, SOBID

          FROM HRP1001

          WHERE OTYPE = LV_OTYPE

          AND      OBJID  = LV_OBJID

          and BEGDA <= TO_NVARCHAR(now(), 'YYYYMMDD')

          and ENDDA >= TO_NVARCHAR(now(), 'YYYYMMDD')

          and PLVAR  = '01';

         

          ARR_MANDT = ARRAY_AGG(:IT_HRP1001.MANDT);

          ARR_OBJID   = ARRAY_AGG(:IT_HRP1001.OBJID);

 

     END WHILE;

 

END FOR;

 

OT_HIERARCHY = UNNEST(:ARR_MANDT, ARR_OBJID) AS ("MANDT", "OBJID");

 

I'm facing issues in ARRAY_AGG function which is not adding rows to ARR_MANDT & ARR_OBJID. It's only storing the latest records only.

 

Kindly please guide me how to use ARRAY_AGG function.

 

Thanks in Advance.

 

Regards,

Ramana.


Viewing all articles
Browse latest Browse all 6412

Trending Articles



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