替代oralce的wm_concat函数
欢迎关注
原⽂链接:
wm_concat函数是oracle拼接字符串常⽤函数,但是这函数并不是oracle官⽅推荐的,估计oracle在后续更新中会悄⽆声息的去除,在oracle 11g之前可以使⽤wm_concat,但是如果拼接字符串超过3000就会报错
Oracle ORA-06502: PL/SQL: 数字或值错误 : 字符串缓冲区太⼩这个错误
解决办法:
官⽅建议⾃⼰建⽴⼀个函数实现相同的⾏列转换功能
第⼀步执⾏:
CREATE OR REPLACE TYPE zh_concat_im
AUTHID CURRENT_USER AS OBJECT
(
CURR_STR clob,
年终报告STATIC FUNCTION ODCIAGGREGATEINITIALIZE(SCTX IN OUT zh_concat_im) RETURN NUMBER,
MEMBER FUNCTION ODCIAGGREGATEITERATE(SELF IN OUT zh_concat_im,
P1 IN VARCHAR2) RETURN NUMBER,
black teaMEMBER FUNCTION ODCIAGGREGATETERMINATE(SELF IN zh_concat_im,
RETURNVALUE OUT clob,
FLAGS IN NUMBER)
RETURN NUMBER,
MEMBER FUNCTION ODCIAGGREGATEMERGE(SELF IN OUT zh_concat_im,
SCTX2 IN zh_concat_im) RETURN NUMBER
);
第⼆步执⾏:
CREATE OR REPLACE TYPE BODY zh_concat_im
japane movementIS
STATIC FUNCTION ODCIAGGREGATEINITIALIZE(SCTX IN OUT zh_concat_im)
RETURN NUMBER
IS
BEGIN
SCTX := zh_concat_im(NULL) ;
RETURN ODCICONST.SUCCESS;
END;宝贝的英文怎么写
MEMBER FUNCTION ODCIAGGREGATEITERATE(SELF IN OUT zh_concat_im,
P1 IN VARCHAR2)
purRETURN 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 zh_concat_im, RETURNVALUE OUT clob,
garage怎么读FLAGS IN NUMBER)
RETURN NUMBER待遇的意思
IS
3369BEGIN
RETURNVALUE := CURR_STR ;
varietyRETURN ODCICONST.SUCCESS;
END;
MEMBER FUNCTION ODCIAGGREGATEMERGE(SELF IN OUT zh_concat_im, SCTX2 IN zh_concat_im)
RETURN NUMBER
ctsbIS
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 zh_concat(P1 VARCHAR2) RETURN clob AGGREGATE USING zh_concat_im ;
实际使⽤例⼦:仅供参考
直接使⽤zh_concat替换wm_concat函数即可 不⽤动原有sql结构,在此作为事件记录