I have a question and maybe someone has gone through the same problem and can help. I'm working on a project where I need to create a hierarchical XML document from hierarchical data. I have the query that pulls the data and the problem I'm facing is that the query is too long for the querystring parameter accepted by DBMS_XMLGEN.newcontextfromhierarchy (queryString varchar2)
I tried using a with clause but that was not recognized when selecting from the resultset which looks understandable.
  SELECT XMLRoot( XMLELEMENT
          ("clients",
           (SELECT DBMS_XMLGEN.getxmltype
                      (DBMS_XMLGEN.newcontextfromhierarchy
                          ('SELECT level,
              XMLElement("client",
                         XMLElement("client_number", client_number),
                         XMLElement("parent_client_number", parent_client_number),
                         XMLElement("level", level),
                         XMLElement("client_level", client_level))
         FROM clients
  START WITH parent_client_number = ''900002''
  CONNECT BY PRIOR  client_number = parent_client_number
  ORDER siblings BY parent_client_number'))
              FROM DUAL), (XMLELEMENT())),VERSION '1.0') as XMLDATA
  FROM DUAL;
The query is much longer than the one above but that will give an idea of what I'm running.
This is the exact error I'm getting.
ORA-01704: string literal too long
Has anyone faced this problem before and have any ideas of how to overcome it?
Thanks, Sergio