Fetch MULTIPLE ROWS and STORE in 1 VARIABLE - ORACLE STORED PROCEDURE

前端 未结 4 1362
故里飘歌
故里飘歌 2021-02-06 00:55

I am working on ORACLE STORED PROCEDURES and I have a doubt. I have a query which fetches more than 1 row and I want to store all those 3 row\'s values in 1 Variable. Can anybod

4条回答
  •  有刺的猬
    2021-02-06 01:39

    Depending on your Oracle version(>= 11G(11.2)), you can use LISTAGG:

    SELECT LISTAGG(STUDENT_NAME,',')  WITHIN GROUP (ORDER BY STUDENT_NAME)
    FROM STUDENT.STUDENT_DETAILS
    WHERE CLASS_ID= 'C';
    

    EDIT: If your Oracle version is inferior to 11G(11.2), take a look here

提交回复
热议问题