Oracle SQL过程中的标识符无效

时间:2012-03-23 11:16:12

标签: oracle procedure

我收到错误(8,3):PL / SQL:忽略SQL语句和错误(8,10):PL / SQL:ORA-00904:“XMLELEMENT”:以下过程中的标识符无效:

    CREATE OR REPLACE PROCEDURE GETXMLTREE
    (
      p_ESTABELECIMENTOID IN NUMBER  
    , MYXML OUT VARCHAR2  
    )
    AS
    BEGIN
    SELECT XMLELEMENT --line 8
    into MYXML
        ("root",
          (select dbms_xmlgen.getxmltype 
            (dbms_xmlgen.newcontextfromhierarchy
              ('SELECT level,
                XMLElement("item",XMLAttributes(osusr_kfa_estabele.id as "id"),
                  XMLElement("content", XMLElement("name", nomecompleto)))          
                  from osusr_kfa_estabele
                  start with osusr_kfa_estabele.id = p_ESTABELECIMENTOID 
                  connect by nocycle prior osusr_kfa_estabele.id = osusr_kfa_estabele.estabelecimetnopaiid' ))
          from dual))
    from dual;

    END GETXMLTREE;

为什么会发生这种情况的任何线索? 感谢

1 个答案:

答案 0 :(得分:6)

您的INTO位置错误。尝试:

SELECT XMLELEMENT --line 8
        ("root",
          (select dbms_xmlgen.getxmltype 
            (dbms_xmlgen.newcontextfromhierarchy
              ('SELECT level,
                XMLElement("item",XMLAttributes(osusr_kfa_estabele.id as "id"),
                  XMLElement("content", XMLElement("name", nomecompleto)))          
                  from osusr_kfa_estabele
                  start with osusr_kfa_estabele.id = p_ESTABELECIMENTOID 
                  connect by nocycle prior osusr_kfa_estabele.id = osusr_kfa_estabele.estabelecimetnopaiid' ))
          from dual))
    into MYXML
    from dual;