Yu Xu, thanks for the reply; so far, I haven't seen any objections or 
explanations as to why this shouldn't be done. I tested it in Oracle, and it 
works. As I understand it, however, this isn't possible in Postgres.

The reason I’m asking is that I need to implement 
"XMLType.createXML(CURSOR(...))". 
One way to do this is by calling a table-valued function, something like 
"createXml((select value from table(toXmlStr(cursor(...)))))", but that seems a 
bit unnatural and complex. 
That’s what led me to consider cursor support for UDFs. I looked into 
`MAP(query)` and `ARRAY(query)`, but they are implemented as special operators 
that I wouldn't be able to replicate at runtime or am I mistaken? 
Is there perhaps a better overall approach to solving this problem?

Julian Hyde, as I described earlier, I have a task to implement the 
UDF(User-Defined Function) "XMLType.createXML(CURSOR(...))" so that one can 
write queries like this, for example:
SELECT
    d.deptno,
    d.dname,
    CREATE_XML(
        CURSOR(
            SELECT
                e.empno,
                e.ename,
                e.job,
                e.sal
            FROM emp e
            WHERE e.deptno = d.deptno
            ORDER BY e.ename
        )
    ) AS emp_xml
FROM dept d
ORDER BY d.dname;

Reply via email to