关于ORACLE
我有一个函数可以返回一些xml值,但每当有任何聚合函数时(比如当前函数的COUNT()),它会给我一个错误,如
ORA-00978: nested group function without GROUP BY
建议我这个解决方案是什么?
以下是我的功能:
CREATE OR REPLACE FUNCTION funxmlresultAGGTest (abc varchar2) RETURN CLOB AS my_xml CLOB; BEGIN SELECT XMLELEMENT ("DATASET", XMLAGG (XMLELEMENT ("ROW", XMLFOREST (COUNT (*) AS count1) ) ) ).getclobval () INTO my_xml FROM pam_tab; RETURN my_xml; END;
提前致谢...
答案 0 :(得分:0)
由于您只有一个列,我建议您进行以下更改:
SELECT XMLELEMENT (
"DATASET",
XMLAGG (XMLELEMENT ("ROW", XMLFOREST (COUNT ( * ) AS count1)))
).getclobval ()
INTO my_xml
FROM pam_tab
GROUP BY 1;