Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching


当前位置: 首页 » 技术文章 » Oracle 12c

在12c上使用wm_concat

WM_CONCAT是Oracle内部的一个函数,在不同版本,这个函数的返回值是不一样的。Oracle对这个函数也没有明确说明,当然也不建议使用。在12c上这个函数就更不用说了,如果要用,最好自己写个函数来实现,因为升级可能会因为这个遇到问题,之后还支持不支持这个函数,还是个问题。如果急用,下面的可作为一个Workaround。

CREATE OR REPLACE TYPE WMSYS.WM_CONCAT_IMPL AS OBJECT  
(  
CURR_STR VARCHAR2(32767),   
STATIC FUNCTION ODCIAGGREGATEINITIALIZE(SCTX IN OUT WM_CONCAT_IMPL) RETURN NUMBER,  
MEMBER FUNCTION ODCIAGGREGATEITERATE(SELF IN OUT WM_CONCAT_IMPL,  
P1 IN VARCHAR2) RETURN NUMBER,  
MEMBER FUNCTION ODCIAGGREGATETERMINATE(SELF IN WM_CONCAT_IMPL,  
RETURNVALUE OUT VARCHAR2,  
FLAGS IN NUMBER)  
RETURN NUMBER,  
MEMBER FUNCTION ODCIAGGREGATEMERGE(SELF IN OUT WM_CONCAT_IMPL,  
SCTX2 IN WM_CONCAT_IMPL) RETURN NUMBER  
);  
/  
 
 
CREATE OR REPLACE TYPE BODY WMSYS.WM_CONCAT_IMPL  
IS  
STATIC FUNCTION ODCIAGGREGATEINITIALIZE(SCTX IN OUT WM_CONCAT_IMPL)  
RETURN NUMBER  
IS  
BEGIN  
SCTX := WM_CONCAT_IMPL(NULL) ;  
RETURN ODCICONST.SUCCESS;  
END;  
MEMBER FUNCTION ODCIAGGREGATEITERATE(SELF IN OUT WM_CONCAT_IMPL,P1 IN VARCHAR2)  
RETURN NUMBER  
IS  
BEGIN  
IF(CURR_STR IS NOT NULL) THEN  
CURR_STR := CURR_STR || ',' || P1;  
ELSE  
CURR_STR := P1;  
END IF;  
RETURN ODCICONST.SUCCESS;  
END;  
MEMBER FUNCTION ODCIAGGREGATETERMINATE(SELF IN WM_CONCAT_IMPL,RETURNVALUE OUT VARCHAR2,FLAGS IN NUMBER)  
RETURN NUMBER  
IS  
BEGIN  
RETURNVALUE := CURR_STR ;  
RETURN ODCICONST.SUCCESS;  
END;  
MEMBER FUNCTION ODCIAGGREGATEMERGE(SELF IN OUT WM_CONCAT_IMPL,SCTX2 IN WM_CONCAT_IMPL)  
RETURN NUMBER  
IS  
BEGIN  
IF(SCTX2.CURR_STR IS NOT NULL) THEN  
SELF.CURR_STR := SELF.CURR_STR || ',' || SCTX2.CURR_STR ;  
END IF;  
RETURN ODCICONST.SUCCESS;  
END;  
END;  
/  

CREATE OR REPLACE FUNCTION WMSYS.WM_CONCAT(P1 VARCHAR2)  
RETURN VARCHAR2 AGGREGATE USING WM_CONCAT_IMPL ;  
/  

create public synonym WM_CONCAT_IMPL for WMSYS.WM_CONCAT_IMPL  
/  
create public synonym WM_CONCAT for WMSYS.WM_CONCAT  
/  
 
grant execute on WM_CONCAT_IMPL to public  
/  
grant execute on WM_CONCAT to public  
/  



关键词:12c 

相关文章

在12c上使用wm_concat
Exadata with database 12.2
如何在oracle 12c中正确的应用补丁?
在OEL6.8上安装12.2 RAC
Oracle Database 12.2 Hands-On Lab
How to create single physical standby for RAC
12c 安装、配置和使用GDS/GSM
12c 如何通过DG Broker配置far_sync
Upgrade 11gR2 RAC database to 12.1.0.2 with DBUA
Upgrade 11gR2 RAC Grid Infrastructure to 12.1.0.2
12c RAC和RAC One Node之间相互转换
12c Admin-Managed Database和Policy-Managed Database之间相互转换

联系我们

韩朝阳



    Phone:186-9589-1286

    E-mail:ohsdba@qq.com

    微  信: ohsdba


电话(186-9589-1286)

QQ(375349564)

微信(ohsdba)


常用链接

Oracle
eDelivery
My Oracle Support

Exadata 12.1 Document

Exadata 12.2 Document

Oracle 11gR2 Document

Oracle 12cR1 Document

Oracle 12cR2 Document

GoldenGate 12c

Oracle Fusion Middleware

Mysql Document

PostgreSQL

Python

github

sourceforge



Top
Cell186-9589-1286
QQ 375349564
E-mail ohsdba@qq.com