oracle pl/sql 结果成一个字符串

2021-12-24 00:00:00 sql oracle stored-procedures plsql

我正在尝试创建一个简单的存储过程,将查询结果存储到一个字符串中.

I'm trying to create a simple stored procedure that stores queried result into one string.

v_string1 varchar2(100);

Select column1
From dual;

会回来

column 1
--------
aaaa
bbbb
cccc

我想将aaaa、bbbb、cccc"存储到 v_string1 中.我能想到的只是一个光标......有没有更好的方法来处理这个问题?

I want to store "aaaa, bbbb, cccc' into v_string1. And all I can think of is a Cursor... Is there a better way to handle this?

推荐答案

使用 SQL Fiddle:

select LISTAGG(name, ',') WITHIN GROUP (ORDER BY 1) AS names
from temp_table

相关文章