日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

oracle一行拆多行函数,Oracle 实现多行转换成一行 使用oracle 10g collect函数

發(fā)布時間:2024/10/8 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle一行拆多行函数,Oracle 实现多行转换成一行 使用oracle 10g collect函数 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

在Oracle 10g中,新增加了一個聚合函數(shù)

collect:Takes a column of any type and creates a nested table of the input type out of the rows selected

1、創(chuàng)建數(shù)組類型

create or replace type varchar2_app as table of varchar2(2000);

2、創(chuàng)建format_string格式化輸出函數(shù)

create or replace function format_string(v_table in varchar2_app) return varchar2 is

Results varchar2(30000);

begin

for i in 1 .. v_table.count loop

Results :=Results||','||v_table(i);

end loop;

--去掉第一個逗號--

return(substr(Results,2));

end format_string;3、開始使用

select object_type,

format_string(CAST(COLLECT(object_name) AS varchar2_app)) AS object_name

from user_objects

group by object_type;

注意:

COLLECT函數(shù)后要用類型varchar2_app數(shù)組類型

總結(jié)

以上是生活随笔為你收集整理的oracle一行拆多行函数,Oracle 实现多行转换成一行 使用oracle 10g collect函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。