我有一个存储过程P_FP_GET_PATTERN
。我希望以下列格式输出
PATTERN_ID |PATTERN_NAME | SHIFT
1 Pattern 1 A,B,C,B,A
2 Pattern 2 C,B,A,C
我在SYS_REFCURSOR ALL_RESULT_SET
中获取此输出。我需要以XML格式传递它。但是我将该输出放在ALL_RESULT_SET_XML
中,这是我使用XMLTYPE存储过程的out参数ALL_RESULT_SET_XML:= XMLTYPE(ALL_RESULT_SET);
我得到一个错误
Error encountered: ORA-31061: XDB error: special char to escaped char conversion failed.
由于使用LISTAGG()函数显示的列,我收到此错误。有人可以告诉我如何处理这个问题吗?
我的存储过程
create or replace
PROCEDURE P_FP_GET_PATTERN
(
ALL_RESULT_SET_XML OUT XMLTYPE,
P_MESSAGE_ALL OUT VARCHAR2
)
AS
V_ERROR VARCHAR2(2000);
ALL_RESULT_SET SYS_REFCURSOR;
BEGIN
OPEN ALL_RESULT_SET FOR
SELECT PM.PATTERN_ID ,PM.PATTERN_NAME,
LISTAGG(SM.SHIFT_NUMBER) WITHIN GROUP (ORDER BY PD.INSTANCE_DAY) "SHIFT"
FROM T_FP_PATTERN_MASTER PM,
T_FP_PATTERN_DETAILS PD,
T_FP_SHIFT_MASTER SM
WHERE SM.SHIFT_ID= PD.SHIFT_ID
AND PM.PATTERN_ID = PD.PATTERN_ID
GROUP BY PM.PATTERN_NAME,PM.PATTERN_ID;
--Adding output in XML output parameter
ALL_RESULT_SET_XML:= XMLTYPE(ALL_RESULT_SET);
EXCEPTION
WHEN OTHERS
THEN
V_ERROR := SUBSTR(SQLERRM,1,1000);
P_MESSAGE_ALL := 'Error encountered: '||V_ERROR ;
END;