dbms_xmlgen

Hi all

How can I solve this?  I understand that some value of my data are digital.

Error report:

ORA-06502: PL/SQL: digital error or value

ORA-06512: at line 9 level

06502 00000 - "PL/SQL: digital error or the value of %s.

* Cause:

* Action:

Here is my code,

value long 8000

Set serveroutput size unlimited

set pagesize 10000

set linesize 900

coil resultxml.txt

declare

CTX dbms_xmlgen.ctxhandle;

CLOB c;

Start

CTX: = dbms_xmlgen.newcontext ("SELECT A.* FROM PERSON_TABLE A, PERSON_MAPPING B WHERE A.PERID = B.PERID AND B.MAPID AS"ENT %"ORDER BY A.PERID ASC");

-Indicator EMPTY_TAG

dbms_xmlgen. SETNULLHANDLING (ctx, 2);

c: = dbms_xmlgen.getxml (ctx);

dbms_output.put_line (c);

end;

/

spool off;

Depending on your error message, the error is on line 9 that is DBMS_OUTPUT. Put_line in your code.

So I think that your output CLOB is greater than 32 KB. In this case, you will get this error. Check this

I have a small query table and all is good

SQL> declare
  2    ctx dbms_xmlgen.ctxhandle;
  3    c clob;
  4  begin
  5    ctx := dbms_xmlgen.newcontext('select * from dept');
  6    dbms_xmlgen.SETNULLHANDLING (ctx, 2);
  7    c := dbms_xmlgen.getxml(ctx);
  8    dbms_output.put_line (c);
  9  end;
 10  /


 
  10
ACCOUNTING
  NEW YORK
 
 
20
  RESEARCH
  DALLAS
 

  30
  SALES
  CHICAGO
 

  40
  OPERATIONS
  BOSTON

 
  50
  IT
  INDIA



PL/SQL procedure successfully completed.

And when I go to a bigger

SQL> declare
  2    ctx dbms_xmlgen.ctxhandle;
  3    c clob;
  4  begin
  5    ctx := dbms_xmlgen.newcontext('select * from all_objects');
  6    dbms_xmlgen.SETNULLHANDLING (ctx, 2);
  7    c := dbms_xmlgen.getxml(ctx);
  8    dbms_output.put_line (c);
  9  end;
 10  /
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 8

SQL>

If your problem is with DBMS_OUTPUT. PUT_LINE

Tags: Database

Similar Questions

  • dbms_xmlgen - what is the right way to reuse a context?

    With the help of dbms_xmlgen.setBindValue () should keep a context and re-use.

    But it seems that execution is slower than the use of dbms_xmlgen.newContext () and dbms_xmlgen.closecontext () each time

    ???

    Kind regards
    Frank

    In my opinion, you use a version of overload undocumented GETXMLTYPE. Do not use undocumented features. Try to use

    v_xml_doc: = dbms_xmlgen. GetXmlType (v_ctx);

    And what you want to achieve by this loop for?

  • dbms_xmlgen. GetXml with single quotes

    Can you get it someone please let me know what is wrong with this query. I try to convert the long and CLOB type. I wanted to convert long to varchar2 and to do this, I am to convert the long to clob or varchar2 clob.

    The query works fine when doing a rownum = 1 in the dynamic query but I would like to read carefully all the constraints so tried the underside and its failure with an error message for an unexpected end of SQL command.

    -with rownum

    SELECT dbms_lob.substr (longtoclob, 4000, 1) text

    of the double.

    (select (dbms_xmlgen.getxml ("SELECT t.search_condition ALIASLONG

    OF All_Constraints t WHERE rownum = 1')) longtoclob

    the double) Y where DBMS_LOB. GETLENGTH (Y.longtoclob) > 0;

    -generic query

    Select (SELECT (dbms_xmlgen.getxml (Q'[select search_condition in all_contstaints where cosntraint_name = ']' | constraint_name |))) Q '[']')) text, constraint_name from

    ALL_CONSTRAINTS

    where rownum < = 3;

    -generic query

    Select (SELECT (dbms_xmlgen.getxml (Q'[select search_condition in all_contstaints where cosntraint_name = ']' | constraint_name |))) Q '[']')) text, constraint_name from

    ALL_CONSTRAINTS

    where rownum<>

    'A few' bad stuff here:

    -keyword SELECT extra

    -typos in names of objects

    -DBMS_XMLGEN.getXML will give you a CLOB that represents a dataset XML to canonical format, not the search_condition directly necessary

    It is more what you are looking for, but know it's slow:

    select constraint_name
         , xmlcast(
             dbms_xmlgen.getxmltype(
               'select search_condition from all_constraints where constraint_name = ' || dbms_assert.enquote_literal(constraint_name)
             )
             as varchar2(4000)
           ) as text
    from all_constraints
    where rownum <= 3 ;
    

    (XMLCAST is 11g only, use the extractValue on lower versions)

  • Problems with DBMS_XMLGEN.getXML add features

    Hello

    I use DBMS_XMLGEN on 11 GR 2.

    The documentation Pages of PL/SQL and Types Reference 11 GR 2 (July 2013) reads as follows:

    GETXML functions

    This function returns the XML document. The function is overloaded.

    Syntax

    Gets the XML document from the maximum number of rows specified. It

    adds the XML in the CLOB passed Use this version of GETXML

    To avoid extra CLOB copies and reuse the same CLOB for subsequent functions

    calls. Due to the CLOB reuse, this GETXML Functionscall is potentially more

    effective:

    DBMS_XMLGEN. GETXML)

    CTX IN ctxHandle,

    tmpclob IN OUT NCOPY CLOB,

    dtdOrSchema in numbers: = NONE)

    RETURN A BOOLEAN VALUE;

    11 GR 2 Guide (February 2014) developer Oracle DB XML stipulates the following:
    Parameters

    getXML (ctx IN ctxHandle,

    clobval IN OUT NCOPY clob,

    dtdOrSchema in numbers: = NONE);

    CTX -The context handle from call

    newContext.

    clobval (IN/OUT) - the CLOB to which the XML document is

    being attached,

    dtdOrSchema -If you need to generate the DTD or

    Schema. This parameter is NOT supported.

    Use this version of the function getXML, in order to avoid any supplement

    CLOB copies and if you want to reuse the same CLOB for

    subsequent calls. This getXML call is more effective than the other

    flavor, even if it means that you create the LOB reference.

    When you generate the XML, the number of lines specified by the

    setSkipRows call are ignored, then the maximum number of

    ranks as specified by the setMaxRows call (or all if

    not specified) is read and converted into XML. Use of the

    getNumRowsProce

    I'm bringing 2 parts of XML document.  I use 2 hierarchical queries.  One to generate hierarchical header of a table and another information to generate information of hierarchical detail to a separate table. My code is generally as follows:

    DECLARE

    hdrctx DBMS_XMLGEN.ctxHandle;

    detailctx DBMS_XMLGEN.ctxHandle;

    hdrdoc CLOB.

    BOOLEAN success;

    hdrqry VARCHAR2 (2000): = ' SELECT LEVEL, XMLELEMENT (EVALNAME HTAGNAME, HTAGVAL) OF HDRTABLE

    CONNECT HSUBSEQ = PRIOR HGRPSEQ';

    --

    detailqry VARCHAR2 (2000): = ' SELECT LEVEL, XMLELEMENT (EVALNAME DTAGNAME, DTAGVAL) OF DETAILTABLE

    CONNECT DSUBSEQ = PRIOR DGRPSEQ';

    BEGIN

    hdrctx: = DBMS_XMLGEN.newContextFromHierarchy (hdrqry);

    detailctx: = DBMS_XMLGEN.newContextFromHierarchy (detailqry);

    DBMS_LOB.CREATETEMPORARY (hdrdoc, true);

    DBMS_XMLGEN. GetXml (hdrctx, hdrdoc);

    -dbms_output.put_line (hdrdoc);

    DBMS_XMLGEN. GetXml (detailctx, hdrdoc);

    DBMS_XMLGEN.closeContext (hdrctx);

    DBMS_XMLGEN.closeContext (detailctx);

    dbms_output.put_line (hdrdoc);

    DBMS_LOB. FREETEMPORARY (hdrdoc);

    END;

    I also tried the next iteration:

    BEGIN

    hdrctx: = DBMS_XMLGEN.newContextFromHierarchy (hdrqry);

    detailctx: = DBMS_XMLGEN.newContextFromHierarchy (detailqry);

    DBMS_LOB.CREATETEMPORARY (hdrdoc, true);

    hdrdoc: = DBMS_XMLGEN.getXML (hdrctx);

    -dbms_output.put_line (hdrdoc);

    DBMS_XMLGEN. GetXml (detailctx, hdrdoc);

    DBMS_XMLGEN.closeContext (hdrctx);

    DBMS_XMLGEN.closeContext (detailctx);

    dbms_output.put_line (hdrdoc);

    DBMS_LOB. FREETEMPORARY (hdrdoc);

    END;

    The two sources of documentation indicates that version 3 of overload of getXML parameter adds the CLOB parameter that is passed and yet I am not able to get the details to add to the header.  If I Uncomment the first put_line I get a document of xml output containing the header as expected information.  However, the second put_line outputs of an xml document that contains only the detail information and none of the header information.  It is not adding as stated in the documentation, but substitute instead.  Any ideas what is happening here and how I can get the feature of adding such as specified in the documentation?

    An additional but trivial problem is the difference in the documentation.  Documentation packages and types indicates that 3 parameter getXML overload returns a BOOLEAN value.  DB XML Dev Guide does not indicate this.  When I use this, the call works as a process and not a function, but I'm failed in the 3rd parameter, which must by default to NONE.  I want to just make sure that using the 2 explicit and implicit parameters 1 is not ending up with me call the wrong version.

    Thanks in advance for any help you can give me on this point,

    Paul

    Because that the additional XML prologue is a specific, defined in section it is easy to remove.

    The best way to get something is to not generate it.

    This is the meeting of the 2 segments arbitrarily dimensions and structured it's much more embarrassing for me.

    What you mean?

    I'll look into the possibility of restructuring in those non-hierarchical hierarchical queries as a work-around.

    Don't bother it.

    Simply add two structures manually instead of using a 'function' who obviously don't get you any advantage.

    for example

    DECLARE

    hdrctx DBMS_XMLGEN.ctxHandle;

    detailctx DBMS_XMLGEN.ctxHandle;

    doc CLOB.

    hdrqry VARCHAR2 (2000): = ' SELECT LEVEL, XMLELEMENT ("emp", xmlattributes (empno as "id")) FROM scott.emp

    CONNECT BY prior empno = mgr

    Start with mgr is null';

    detailqry VARCHAR2 (2000): = ' SELECT LEVEL, XMLELEMENT ("emp2", xmlattributes (empno as "id")) FROM scott.emp

    CONNECT BY prior empno = mgr

    Start with mgr is null';

    BEGIN

    hdrctx: = dbms_xmlgen.newContextFromHierarchy (hdrqry);

    detailctx: = dbms_xmlgen.newContextFromHierarchy (detailqry);

    DBMS_LOB.CREATETEMPORARY (doc, true);

    Select xmlserialize (document

    XmlElement ("root"

    dbms_xmlgen.getxmltype (hdrctx)

    dbms_xmlgen.getxmltype (detailctx)

    )

    as clob dash

    )

    in the doc

    Double;

    dbms_xmlgen.closeContext (hdrctx);

    dbms_xmlgen.closeContext (detailctx);

    dbms_output.put_line (doc);

    DBMS_LOB.freeTemporary (doc);

    END;

    /

    output:

    
      
        
          
            
          
        
        
          
          
          
          
          
        
        
          
        
      
      
        
          
            
          
        
        
          
          
          
          
          
        
        
          
        
      
    
    
  • ORA-06512: at "SYS." DBMS_XMLGEN", (ORA-00942: table or view does not exist)

    Hey guys, it's Xev.

    I decide to use SQL and XML and it works in a scenario, but in another scenario, is not.

    Here's the Code, I'm passing to two variables, first of all, I spend in the table table_name, and then I spend in the schema.

    If I connected it with "user" and that it seeks it's own pattern, he found the results, as for example, but if I try to run this code while not

    connected to the same user I'm looking for more, I get this error.

    ORA-19202: an error has occurred in the processing of XML

    ORA-00942: table or view does not exist

    ORA-06512: at "SYS." DBMS_XMLGEN", line 288

    ORA-06512: at line 1

    19202 00000 - "an error has occurred in the treatment of XML %s.

    * Cause: An error occurred during the processing of the XML function

    * Action: Check the given error message and resolve the problem appropriate

    /*-------------------------------------------------------------------------------

    This code works only you are connected to the user you are looking on.

    But if you're looking for a different user tables, it is kicking up and gives the above XML error...

    */

    SET SERVEROUTPUT ON

    exec DBMS_OUTPUT. ENABLE (1000000);

    Search_string VAR VARCHAR2 (28)

    EXEC: search_string: = ' ^ [0-9]{3}-[0-9]{2}-[0-9]{4}$']

    COLUMN "Keyword" FORMAT A28

    COLUMN 'Table' FORMAT A9

    COLUMN ' column value / "FORMAT A50

    SELECT DISTINCT SUBSTR (: search_string, 1: 28) "keyword."

    SUBSTR (table_name, 1, 14) "table."

    SUBSTR (t.column_value.getstringval (), 1, 50) ' / value of the column.

    OF dba_tab_cols.

    -where owner = ('& SCHEMA_NAME')

    TABLE

    (XMLSEQUENCE

    (DBMS_XMLGEN. GETXMLTYPE

    ("SELECT" | column_name |)

    'FROM ' | table_name |

    "WHERE REGEXP_LIKE.

    (' | column_name |) ','''

    || : search_string. ''')'

    () .extract (' LINES/rowset / * ""))) t

    -WHERE table_name IN ("FIND_TEST")

    WHERE table_name = upper ('& table_name')

    AND the OWNER = upper ('& SCHEMA_NAME')

    ORDER BY "Table".

    /

    Can someone please explain how works (DBMS_XMLGEN) and why it is throwing this error?

    Thank you

    Xev.

    It has nothing to do with DBMS_XMLGEN. GETXMLTYPE. It simply means the user running your SQL has no select privileges on the table & SCHEMA_NAME. & TABLE_NAME.

    SY.

  • dbms_xmlgen-&gt; create oracle XML attribute with value type

    I use the dbms_xmlgen to create my xml message and I use the oracle TYPEs to create xml message elements.

    I need to create something like this:
    < type Emp 'name' = > xyz < / Emp >

    I tried to create the type as below
    create type emp_t as an object ("type" "@type")...

    But do not know how I need to set the value of this attribute.

    Help, please. Thanks in advance for your help.

    Can be

    SQL> select * from v$version where rownum=1;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    
    SQL>
    SQL> select  dbms_xmlgen.getxml('select ename, ''name'' as "@type" from emp') from dual;
    
    DBMS_XMLGEN.GETXML('SELECTENAM
    --------------------------------------------------------------------------------
    
    
     
      SMITH
     
     
      ALLEN
     
     
      WARD
     
     
    
    SQL> 
    
  • Add a xmlns tag to the XML using DBMS_XMLGEN

    I'm using the version of Oracle version 10.1.0.4.2.

    I want to create an xml file according to some data in the relational database tables. For the same thing, I created object types and discovers with the types of objects, since the data is divided into several tables.

    Then, I used DBMS_XMLGEN.getxml to generate xml with queries from the view of the object.

    Y at - it an option to add the xmlns attribute in the xml file generated.

    Please let me know if any additional details are needed.

    If you want to add the namespace declaration to the root element, I don't think it's possible with DBMS_XMLGEN directly.
    You can ask DBMS_XMLGEN to treat some of the fields of the object as XML attributes by prefixing with '@' (for example '@my_attribute'), but you can't control which for bounding of the elements.

    A possible solution is to add it later, using XSLT, or insertChildXML, but apparently it is not available in your version.

    However...

    For the same thing, I created object types and discovers with the types of objects, since the data is divided into several tables.

    Because the data from different tables, why not use SQL and SQL/XML functions to build the document?
    This is simple, simple and needs no additional items.

    select xmlelement("Departments",
             xmlattributes('http://xmlns.example.org' as "xmlns")
           , xmlagg(
               xmlelement("Department",
                 xmlattributes(d.deptno as "Id")
               , xmlelement("Name", d.dname)
               , xmlelement("Employees"
                 , xmlagg(
                     xmlelement("Employee",
                       xmlattributes(e.empno as "Id")
                     , xmlforest(
                         e.ename as "Name"
                       , e.job as "Job"
                       )
                     ) order by e.empno
                   )
                 )
               ) order by d.deptno
             )
           )
    from scott.dept d
         join scott.emp e on e.deptno = d.deptno
    group by d.deptno, d.dname
    ;
    

    Output:

    
      
        ACCOUNTING
        
          
            CLARK
            MANAGER
          
          
            KING
            PRESIDENT
          
          
            MILLER
            CLERK
          
        
      
      
        RESEARCH
        
          
            SMITH
            CLERK
          
          
            JONES
            MANAGER
          
          
            FORD
            ANALYST
          
        
      
      
        SALES
        
          
            ALLEN
            SALESMAN
          
          
            WARD
            SALESMAN
          
          
            MARTIN
            SALESMAN
          
          
            BLAKE
            MANAGER
          
          
            TURNER
            SALESMAN
          
          
            JAMES
            CLERK
          
        
      
    
    
  • DBMS_XMLGEN. GETXML confusing WHERE the condition of clause?

    I can't quite wrap my head around that, but I found the following query

    Select * from user_views
    where dbms_xmlgen.getxml ("select text from user_views where view_name =" "|") view_name | ') like '% view_table_name % '.

    I am totally confuse everything, that's what makes the WHERE condition in the query?

    When I run the game "highlight text" it returns nothing

    If anyone knows why the WHERE clause is necessary?

    Thank you

    rodneyc8063 wrote:
    I don't understand why there are extra, extra quotes | and the "solomon_is_cool".

    Additional citations have nothing to do with dbms_xmlgen. In string literals Oracle must be in quotes by acronym. So what do you do if literal contains a quotation, for example O'Reily? The rule is, apostrophe inside the quoted string must be preceded by a second single quote. Thus, to produce the O string literal 'Reily, one must use 'O' Reily'. Now, back to dbms_xmlgen.get_xml. She waits for the SQL statement as a parameter. What SQL statement we want to produce? It would be:

    Select the text from user_views where view_name = "some-view-name."

    Right? Then, how the chain of the SQL statement above should look like? One way is to double single quotes:

    "Select the text from user_views where view_name =" some-view-name "'.

    But some-name-of-view is stored in the column of our query view_name. We have therefore concatenate the piecies which are:

    (1) text select lieral user_views where view_name = '
    (2) column view_name
    (3) literal '

    If we end up having:

    "Select the text from user_views where view_name ="' | view_name | ''''

    Now, you have replaced with solomon_is_cool view_name. This will not work because there is no solomon_is_cool column is user_views. What you probably wanted was:

    "Select the text from user_views where view_name ="solomon_is_cool"'.

    Then:

    dbms_xmlgen. GetXml ("select text from user_views where view_name ="solomon_is_cool"'") would look like to display user named solomon_is_cool text is tiny, which again could be a problem since the names, except between quotes, are stored in the data dictionary for uppercase. In any case, the counting of single quotes in string literals can be confusing. In the new versions of oracle introduced then Q-literals,

    dbms_xmlgen. GetXml ("select text from user_views where view_name =" "|") view_name | '''')

    could be replaced by more readable:

    dbms_xmlgen. GetXml (Q'[select text from user_views where view_name = ']' | view_name |) Q'[']')

    For example:

    SQL> select Q'[select text from user_views where view_name = ']' || view_name || Q'[']' from user_views where rownum < 3;
    
    Q'[SELECTTEXTFROMUSER_VIEWSWHEREVIEW_NAME=']'||VIEW_NAME||Q'[']'
    ------------------------------------------------------------------------------
    select text from user_views where view_name = 'EMP_VW'
    select text from user_views where view_name = 'REMOTE_DDL_VIEW_TEST'
    
    SQL> 
    

    SY.

  • dbms_xmlgen.setXSLT behave differently in 11.2.0.3, output on 1 line

    post response: change the default output of dbms_xmlgen.getxml

    reclassification of 10.2.0.3 on 11.2.0.3
     
    create table table_x (column1 varchar2(10), column2 number) 
     
    insert into table_x values('row1',1);
     
    insert into table_x values('row2',2);
     
    commit;
    GetXml and transformation of xml
    select xmltransform(
          dbms_xmlgen.getxmltype('select column1, column2 from table_x')
        , xmltype(
        '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml"/>
          <xsl:template match="*">
            <xsl:copy>
              <xsl:apply-templates select="*"/>
            </xsl:copy>
         </xsl:template>
         <xsl:template match="ROW/*">
           <COL_DTLS><COL_VALUE><xsl:value-of select="."/></COL_VALUE></COL_DTLS>
         </xsl:template>
       </xsl:stylesheet>'
         )
       ).extract('/*')
       from dual
       ;
    10.2.0.3 on product:
    XMLTRANSFORM(DBMS_XMLGEN.GETXMLTYPE('SELECTCOLUMN1,COLUMN2FROMTABLE_X'),XMLTYPE(
    --------------------------------------------------------------------------------
    <ROWSET>                                                                        
      <ROW>                                                                         
        <COL_DTLS>                                                                  
          <COL_VALUE>row1</COL_VALUE>                                               
        </COL_DTLS>                                                                 
        <COL_DTLS>                                                                  
          <COL_VALUE>1</COL_VALUE>                                                  
        </COL_DTLS>                                                                 
      </ROW>                                                                        
      <ROW>                                                                         
        <COL_DTLS>                                                                  
          <COL_VALUE>row2</COL_VALUE>                                               
        </COL_DTLS>                                                                 
        <COL_DTLS>                                                                  
          <COL_VALUE>2</COL_VALUE>                                                  
        </COL_DTLS>                                                                 
      </ROW>                                                                        
    </ROWSET> 
    Product on 11.2.0.3:
    XMLTRANSFORM(DBMS_XMLGEN.GETXMLTYPE('SELECTCOLUMN1,COLUMN2FROMTABLE_X'),XMLTYPE(
    --------------------------------------------------------------------------------
    <ROWSET><ROW><COL_DTLS><COL_VALUE>row1</COL_VALUE></COL_DTLS><COL_DTLS><COL_VALU
    E>1</COL_VALUE></COL_DTLS></ROW><ROW><COL_DTLS><COL_VALUE>row2</COL_VALUE></COL_
    DTLS><COL_DTLS><COL_VALUE>2</COL_VALUE></COL_DTLS></ROW></ROWSET>    
    Question: How do the output looks like 10.2.0.3? How to ensure that the output is not wound on one line?

    Hello

    See this discussion and the solution: Pretty Print characteristic of the XMLType methods is broken in Oracle 11 g

    Herald tiomela
    http://htendam.WordPress.com

  • Zero error of iteration - the treatment of dynamic sql statements in dbms_xmlgen

    Hello

    I have a procedure that creates a dynamic sql v_sql

    cursor v_curr is
    Select *.
    of btctl_msg_log;

    BEGIN
    Select count (*) in the v_cnt of btctl_msg_log;

    IF v_cnt > 0 THEN
    C1 in v_curr
    LOOP
    v_sql: = "' | ' SELECT * from '. C1.msg_rcrd_src_tbl_nm | |' where rowid = ' | " ' ||'' ' || C1.msg_rcrd_src_tbl_id | " ' ||'' ' ||'' ' ;
    Select DBMS_XMLGEN.getXMLtype (v_sql) in the double v_xml;

    gives me an error

    ORA-19202: an error has occurred in the processing of XML
    ORA-24333: zero number of iterations
    ORA-06512: at "SYS." DBMS_XMLGEN", line 288
    ORA-06512: at line 1

    I don't know why is this error happening.
    Any help much appreciated.

    881575 wrote:
    Hello

    I have a procedure that creates a dynamic sql v_sql

    cursor v_curr is
    Select *.
    of btctl_msg_log;

    BEGIN
    Select count (*) in the v_cnt of btctl_msg_log;

    IF v_cnt > 0 THEN
    C1 in v_curr
    LOOP
    v_sql: = "' | ' SELECT * from '. C1.msg_rcrd_src_tbl_nm | |' where rowid = ' | " ' ||'' ' || C1.msg_rcrd_src_tbl_id | " ' ||'' ' ||'' ' ;
    Select DBMS_XMLGEN.getXMLtype (v_sql) in the double v_xml;

    gives me an error

    ORA-19202: an error has occurred in the processing of XML
    ORA-24333: zero number of iterations
    ORA-06512: at "SYS." DBMS_XMLGEN", line 288
    ORA-06512: at line 1

    I don't know why is this error happening.
    Any help much appreciated.

    Standard when boards (ab) use of EXECUTE IMMEDIATE is to compose the SQL statement in a single VARCHAR2 variable
    Then print the variable before passing to EXECUTE IMMEDIATE.
    COPY the statement & PASTE in sqlplus to validate its correctness.

  • Change the default output of dbms_xmlgen.getxml

    10g 10.2.0.3

    installation program:
    create table table_x (column1 varchar2(10), column2 number) 
    
    insert into table_x values('row1',1);
    
    insert into table_x values('row2',2);
    
    commit;
    Select using getxml:
    select dbms_xmlgen.getxml('select column1, column2 from table_x') from dual;
    
    gives:
    
    <?xml version="1.0"?>
    <ROWSET>
     <ROW>
      <COLUMN1>row1</COLUMN1>
      <COLUMN2>1</COLUMN2>
     </ROW>
     <ROW>
      <COLUMN1>row2</COLUMN1>
      <COLUMN2>2</COLUMN2>
     </ROW>
    </ROWSET>
    How to get:
    <?xml version="1.0"?>
    <ROWSET>
     <ROW>
      <COL_DTLS>
        <COL_VALUE>row1</COL_VALUE>
      </COL_DTLS>
      <COL_DTLS>
        <COL_VALUE>1</COL_VALUE>
      </COL_DTLS>
     </ROW>
     <ROW>
      <COL_DTLS>
        <COL_VALUE>row2</COL_VALUE>
      </COL_DTLS>
      <COL_DTLS>
        <COL_VALUE>2</COL_VALUE>
      </COL_DTLS>
     </ROW>
    </ROWSET>
    In summary.

    1. how to 'inject' the COL_DTLS tag for each piece of old LINE.
    2. how to change each element tag name line to 'COL_VALUE '.

    Note that the < Column1 > tag could change your name to any other tag, I have to be able to handle any valid SQL that generates SQL column names and number of items will change

    DBMS_XMLGEN can control only the names of ROWSET and ROW tags.
    So, if your only entry is a string SQL, then you must postprocess the XML generated, and XSLT can be useful here:

    SQL> select xmltransform(
      2    dbms_xmlgen.getxmltype('select column1, column2 from table_x')
      3  , xmltype(
      4  '
      5    
      6    
      7      
      8        
      9      
     10    
     11    
     12      
     13    
     14  '
     15    )
     16  ).extract('/*')
     17  from dual
     18  ;
    
    XMLTRANSFORM(DBMS_XMLGEN.GETXM
    --------------------------------------------------------------------------------
    
      
        
          row1
        
        
          1
        
      
      
        
          row2
        
        
          2
        
      
    
     
    

    Otherwise, the implementation of PL/SQL:

    DECLARE
    
      ctx   dbms_xmlgen.ctxHandle;
      doc   clob;
    
      xsl   xmltype := xmltype('
      
      
        
          
        
      
      
        
      
    ');
    
      qry   varchar2(2000) := 'select column1, column2 from table_x';
    
    BEGIN
    
      ctx := dbms_xmlgen.newContext(qry);
      dbms_xmlgen.setXSLT(ctx, xsl);
      doc := dbms_xmlgen.getXML(ctx);
      dbms_xmlgen.closeContext(ctx);
    
      dbms_output.put_line(doc);
    
    END;
    /
    
  • Use of dbms_xmlgen.convert to capture the URL

    I use a web service that returns the XML response (see results below). I need to capture the URL in the tag "GetIEPUrlWithAuditResult". I tried this code, but get an ORA-30625: shipping method on NULL SELF argument is not allowed. Is my path of dbms_xmlgen.convert to the correct tag?

    l_xml: = xmltype.createxml (l_clob);
    l_val: = dbms_xmlgen.convert(l_xml.extract('//GetIEPUrlWithAuditResult/text()').getclobval(),1);


    RESULT
    -------------
    <? XML version = "1.0" encoding = "utf-8"? > < xmlns:soap: envelope soap = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" container = "http://www.w3.org/2001/XMLSchema" > < soap: Body > < GetIEPUrlWithAuditResponse xmlns = "http://www.iepdirect.com/CentrisWebServices/IEPViwer" > < GetIEPUrlWithAuditResult > https://www.iepdirect.com/lettersandreports/maintenance/iepviewer.aspx?auditinfo=TEST & amp; viewertoken = cn097c5e6c69a94fbc9dffcd70bd88f2b9 | d0Gpyh6ZEelbL6lMz + ZDWBTyMqsfjkDFPlat6T + 8vMQ = < / GetIEPUrlWithAuditResult > < / GetIEPUrlWithAuditResponse > < / soap: Body > < / envelope soap: >

    Is my path of dbms_xmlgen.convert to the correct tag?

    Half correct.

    Missing namespace mapping, and you will need to add the text() node to the XPath expression to retrieve the value instead of the entire element.

     l_val := dbms_xmlgen.convert(
                l_xml.extract(
                  '//GetIEPUrlWithAuditResult/text()'
                , 'xmlns="http://www.iepdirect.com/CentrisWebServices/IEPViwer"'
                ).getstringval()
              , 1
              );
    

    But, in this case, it is preferable to use extractValue (as she performs the necessary conversions for us):

     select extractvalue(
              l_xml
            , '//GetIEPUrlWithAuditResult'
            , 'xmlns="http://www.iepdirect.com/CentrisWebServices/IEPViwer"'
            )
     into l_val
     from dual;
    
  • DBMS_XMLGEN and cursor

    Hey XML gurus,

    Is it possible to get this dbms_xmlgen.newcontext XML file:

    < HEADER >
    ARN < AIRPORT > < / AIRPORT >
    < / Header >
    < BODY >
    < GATE > 10 < / GATE >
    < / BODY >

    a table called flight consisting of three columns:
    msgid number, varchar2, door number airport
    How would the the sql query looks like not not using xmlelement, xmlforest...
    I'm on Oracle 10G 10.2.

    Concerning
    / Nicklas

    The 'underlying' suggestion is: don't use only not DBMS_XMLGEN at all.

    XMLFOREST cannot cope with null values

    Well, can of XMLElement.

  • Invalid DateFormat for dbms_xmlgen.getxml

    Hello
    I use the dbms_xmlgen.getxml to generate the XML from the table.

    I have problems with the type of data type date.

    For date fields type XML is generated in format DD-MON-AA, but it does not record the passage of time.

    What should I do?

    Hello

    In the absence of an explicit conversion, NLS session parameters are used.

    Thus, two solutions:

    (1) change the setting NLS_DATE_FORMAT for the session:

    ALTER SESSION SET nls_date_format = "DD/MM/YYYY HH24:MI:SS";
    

    (2) use an explicit cast:

    SELECT to_char(your_date_col, 'DD/MM/YYYY HH24:MI:SS'), ...
    FROM ...
    
  • DBMS_XMLGEN package

    Hello

    I have a table with the following columns

    name of the table: TRANSACTION

    columns:
    ID
    STATUS
    CREATEDBY
    CREATED THE


    I want to generate an xml for columns with the following format

    transactions <>
    < transaction >
    < id > 1 < /ID >
    < status > < / status >
    * < audit > *.
    < createdby > LINI < / createdby >
    < createdon > < / < createdon >
    * < / audit > *.
    < / transaction >
    <! - transactions more - >
    < / transactions >

    can it be dione using DBMS_XMLGEN package? I am not able to insert * < audit > * tag between the two. Help, please

    Maybe this:

    SQL> declare
      x   int;
    begin
      x :=
        dbms_xmlgen.newcontext (
          'select id "id", status "status", xmlconcat(xmlelement("createdby", createdby), xmlelement("created_on", created_on)) "audit" from transaction');
      dbms_xmlgen.setrowtag (x, 'transaction');
      dbms_xmlgen.setrowsettag (x, 'transactions');
    
      dbms_output.put_line (dbms_xmlgen.getxml (x));
    end;
    /
    
    
     
      1
      A
      
       LINI  
     
    
    PL/SQL procedure successfully completed.
    

    ?

Maybe you are looking for