Dbms_xmlgen

Dear Sir,
dbms_xmlgen This is the predefined package which is used to generate the xml file in l0g . Is there any predefined package is there for generating the excel file . If it is there which package will help me to generate excel file through predefined packages in 10g.
Please guide me i will do rest of the part
Regards,
Chandrasekhar B.S.

sir
gen_xl_xml package is create, but i can not execute query
what can i do plese help
DECLARE
r NUMBER := 0 ;
BEGIN
gen_xl_xml.create_excel('UTL_DIR', 'employees.xls') ;
gen_xl_xml.create_worksheet( 'sheet1');
-- gen_xl_xml.create_excel_apps ;
gen_xl_xml.create_style( 'sgs1' , 'Courier', 'red',16, TRUE , p_backcolor => 'LightGray', P_underline => 'Single' );
gen_xl_xml.create_style( 'sgs2' , 'Courier', 'blue',12,NULL );
gen_xl_xml.create_style( 'sgs3' , 'Courier', 'green',14,TRUE );
-- increase width OF colum b that IS no 2
gen_xl_xml.set_column_width( 1, 140, 'sheet1' );
gen_xl_xml.set_column_width( 2, 145 , 'sheet1' );
gen_xl_xml.set_column_width( 3, 145, 'sheet1' );
gen_xl_xml.set_row_height( 1, 30 ,'sheet1' );
-- writing the headers
r := r+1 ;
gen_xl_xml.write_cell_char( r,1, 'sheet1', 'empno' ,'sgs1' );
gen_xl_xml.write_cell_char( r,2, 'sheet1', 'ename' ,'sgs1' );
gen_xl_xml.write_cell_char( r,3, 'sheet1', 'sal', 'sgs1' );
-- gen_xl_xml.write_cell_char( r,3, 'Last Name', 'sgs1' );
FOR rec IN (SELECT empno , ename , sal FROM emp where ROWNUM < 10 ) LOOP
r := r+1 ;
gen_xl_xml.write_cell_num( r,1, 'sheet1' , rec.empno, 'sgs3' );
gen_xl_xml.write_cell_char( r,2, 'sheet1' , rec.ename, 'sgs2' );
gen_xl_xml.write_cell_char( r,3, 'sheet1' , rec.sal, 'sgs2');
END LOOP ;
gen_xl_xml.close_file ;
END ;
Error on line 0
DECLARE
r NUMBER := 0 ;
BEGIN
gen_xl_xml.create_excel('UTL_DIR', 'employe
ORA-20101: UTL_FILE raised invalid path, check the directory passed is correct and you have access to it.
ORA-06512: at "SCOTT.GEN_XL_XML", line 142
ORA-06512: at line 4
sir pls help

Similar Messages

  • How to change the default element tag using dbms_xmlgen

    here is my code that generate output for purchase order data. I followed the syntax shown in xml db developer guide.
    I am getting the results but element tags are CAPS letters( As the coloumn names in the type defenitions are stored in CAPS in Oracle). but I need to show in small letters as per my requirement.
    can anyone help me how to change the default tag names for elements.
    ==================================HERE IS THE CODE==================
    DECLARE
    qryCtx DBMS_XMLGEN.ctxHandle;
    result CLOB;
    BEGIN
    qryCtx := DBMS_XMLGEN.newContext
    ('SELECT PODL_H_T
    ( CLOSEDDATETIME ,
    COMPANY ,
    CAST(MULTISET
    (SELECT LINENUMBER ,
    COMPANY ,
    PURCHASEORDERID ,
    ITEM ,
    QUANTITYUM ,
    TOTALQUANTITY
    FROM cpo_wms_podl_LINES
    WHERE PURCHASEORDERID = PH.PURCHASEORDERID) as PurchaseOrderDetailList
    FROM cpo_wms_podl_HEADERS PH ');
    -- now get the result
    DBMS_XMLGEN.setRowSetTag(qryCtx, 'Receipts' );
    DBMS_XMLGEN.setRowTag(qryCtx, 'PurchaseOrder' );
    result := DBMS_XMLGEN.getXML(qryCtx);
    INSERT INTO temp_clob_tab VALUES (result);
    DBMS_XMLGEN.closeContext(qryCtx);
    END;
    -- select * from temp_clob_tab
    ===========create type script=====================
    cpo_wms_podl_HEADERS
    CREATE or replace TYPE PurchaseOrderDetail AS OBJECT(
    LINENUMBER VARCHAR2(400 BYTE),
    COMPANY VARCHAR2(400 BYTE),
    PURCHASEORDERID VARCHAR2(400 BYTE),
    ITEM VARCHAR2(400 BYTE),
    QUANTITYUM VARCHAR2(400 BYTE),
    TOTALQUANTITY NUMBER
    create type PurchaseOrderDetailList as table of PurchaseOrderDetail
    create table temp_clob_tab(result CLOB)
    create type podl_HEADERS_list_t as table of podl_HEADERS_t
    CREATE or replace TYPE PODL_H_T AS OBJECT
    CLOSEDDATETIME DATE,
    COMPANY VARCHAR2(400 BYTE),
    CREATEDDATETIME DATE,
    PURCHASEORDERID VARCHAR2(400 BYTE),
    SHIP_TO VARCHAR2(400 BYTE),
    linelist PurchaseOrderDetailList
    )

    but I need to show in small letters as per my requirement.add alias column names in double quotes as in
    SQL> select dbms_xmlgen.getxmltype('select dname "DeptName", loc "Location" from dept') dept_xml from dual
    DEPT_XML                                                                       
    <ROWSET>                                                                       
      <ROW>                                                                        
        <DeptName>ACCOUNTING</DeptName>                                            
        <Location>NEW YORK</Location>                                              
      </ROW>                                                                       
      <ROW>                                                                        
        <DeptName>RESEARCH</DeptName>                                              
        <Location>DALLAS</Location>                                                
      </ROW>                                                                       
      <ROW>                                                                        
        <DeptName>SALES</DeptName>                                                 
        <Location>CHICAGO</Location>                                               
      </ROW>                                                                       
      <ROW>                                                                        
        <DeptName>OPERATIONS</DeptName>                                            
        <Location>BOSTON</Location>                                                
      </ROW>                                                                       
      <ROW>                                                                        
        <DeptName>SALES</DeptName>                                                 
        <Location>MUNICH</Location>                                                
      </ROW>                                                                       
    </ROWSET>                                                                      
    1 row selected.

  • XML publisher report using dbms_xmlgen (ORA-06502)

    Dear All,
    I have written the below code to generate xml output in Oracle Apps. The code is working fine for less records. But when CLOB size is more than 32k, then
    it giving the ORA-06502 error as fnd_file.put_line(fnd_file.output,v_result) can only write 32k at a time.
    Can anyone let me know how to handle this? Any help on this would be highly appreciated.
    PROCEDURE MAIN ( errbuf OUT VARCHAR2
    ,retcode OUT NUMBER
    ) IS
    TYPE g_query_ref IS REF CURSOR;
    v_query_ref g_query_ref;
    v_handle dbms_xmlgen.ctxhandle;
    v_result clob;
    BEGIN
    OPEN v_query_ref FOR
    SELECT invoice_num,
    description,
    customer_no,
    customer_name
    FROM XX_INVOICE_DETAILS;
    v_handle := dbms_xmlgen.newContext(v_query_ref);
    DBMS_XMLGEN.SETROWTAG (v_handle , 'INVOICE');
    v_result := dbms_xmlgen.getXML(v_handle);
    fnd_file.put_line(fnd_file.output,v_result);
    EXCEPTION
    when others then
    errbuf := sqlerrm;
    retcode := sqlcode;
    fnd_file.put_line(fnd_file.log,’sqlerrm ‘||sqlerrm);
    END MAIN;
    Thanks in Advance.
    Regards,
    Astik

    What you need to do is to chop your CLOB up into smaller strings, something like:
    l_size := DBMS_LOB.getlength (l_clob);
    IF (NVL (l_size, 0) = 0) THEN
    raise_application_error (-20001, 'CLOB is NULL');
    END IF;
    l_offset := 1;
    -- Loop
    WHILE (l_offset <= l_size) LOOP
    l_char := DBMS_LOB.SUBSTR (l_clob,1,l_offset);
    IF (l_char = CHR (10)) THEN
    FND_FILE.NEW_LINE(FND_FILE.output, 1);
    ELSE
    FND_FILE.PUT(FND_FILE.output, l_char);
    END IF;
    -- Increment Offset.
    l_offset:= l_offset+1;
    END LOOP;
    FND_FILE.NEW_LINE(fnd_file.output, 1);

  • Generate XML output using DBMS_XMLGEN.getxmltype and not from rdf

    Hi,
    I have a requirement to display output from a particular table in XL format. Out of all the known possible options, I am planning to use the XML publisher to generate XL output.
    For the data source, instead of using the conventional way of creating XML data using rdf,I am planning to use DBMS_XMLGEN.getxmltype pl/sql procedure to generate the XML output. And from the output, call the template to generate the required Excel output.
    Now, I am using the following code to generate XML output but am not sure how to proceed from here. I need to first print the XML data in the FND Output file after which I was planning to call the 'XML Report Publisher' (XDOREPPB) program and use the current request id to get the excel output but I am not able to find the way to print the XML data in the output file as:
    fnd_file.put_line (fnd_file.output, l_xml_type); - is throwing an error as l_xml_type is an XML data output.
    PROCEDURE xml_main (
    errbuf OUT VARCHAR2
    ,retcode OUT VARCHAR2
    ,p_project_from IN VARCHAR2
    ,p_project_to IN VARCHAR2
    AS
    l_xml_type XMLTYPE;
    BEGIN
    SELECT DBMS_XMLGEN.getxmltype
    ('SELECT fnd_global.conc_request_id
    ,TO_CHAR (segment1)
    ,to_char(start_date,''MM/DD/RRRR'')
    ,to_char(xxmcc_project_details_pkg.current_profit_projection
    (project_id),''999,999,990.90'')
    ,to_char(xxmcc_project_details_pkg.cost_to_date (project_id),''999,999,990.90'')
    ,''1''
    FROM pa_projects_all
    WHERE segment1 BETWEEN NVL (p_project_from, segment1)
    AND NVL (p_project_to, segment1)')
    INTO l_xml_type
    FROM DUAL;
         fnd_file.put_line (fnd_file.output, l_xml_type);
    END xml_main;
    Can anyone point me as to how to publish XML output using a PL/SQL procedure (DBMS_XMLGEN.getxmltype)
    Thanks.

    Pl see if the example included in this presentation helps http://www.oracle.com/technology/products/applications/Events/OOW-2006/EBS/S281401_Sridhar_Bogelli.pdf
    Also, you do not need to explicitly call XDOREPPB in later versions of XML Publisher. If you set up everything correctly (as described in the presentation above and the link below) the Output Post Processor is called automatically after the XML file is generated successfully.
    Another excellent tutorial is at http://www.oracle.com/technology/obe/fusion_middleware/fusion/bi/xmlp_ebiz/index.html
    HTH
    Srini

  • DBMS_XMLGEN, Carriage Returns XSLT to HTML

    Hi,
    I am facing an issue using the DBMS_XMLGEN. I have written a function (see under) that receive A SYS_REFCURSOR and return as a CLOB the XML with eventually transformed using a CLOB containing the passed XSLT code.
    The goal is to reuse several time this functions being called by other function/procedure (see under a sample of one of my procedure) of my package. Those procure/function being called by the front-end (Cold fusion) to retrieve and output the results. My purpose is to make independent of the front end solution the output generation. Any language that can call an Oracle Procedure/Function would be able to process the result with or without a XSLT.
    The issue is the CRLF (chr(10)+chr(13) seems to be lost in the process of the varchar2/clob data type used to generate the XML.
    A solution, is to modify the select statement and adding when necessary select ... replace(thefield,chr(10),'<br/>') thefield ... but this would request a post processing which I am trying to avoid.
    FUNCTION GEN_SYSTEM_GENEXML(
        INQUERYSTRING IN SYS_REFCURSOR,
        inStartRow    IN NUMBER,
        inMaxRows     IN NUMBER,
        inXsltString  IN CLOB)
      RETURN CLOB
    AS
      LHTMLOUTPUT XMLTYPE;
      xmlResult CLOB;
      CTX DBMS_XMLGEN.CTXHANDLE;
      lXMLData XMLType;
    BEGIN
      CTX := DBMS_XMLGEN.NEWCONTEXT(INQUERYSTRING);
      dbms_xmlgen.setNullHandling(ctx, 2);
      dbms_xmlgen.setIndentationWidth(ctx, 0);
      dbms_xmlgen.setRowSetTag(ctx, 'ROOT');
      dbms_xmlgen.setRowTag(ctx, 'item');
      dbms_xmlgen.setskiprows(ctx,inStartRow);
      DBMS_XMLGEN.SETMAXROWS(CTX,INMAXROWS);
      IF LENGTH(INXSLTSTRING) <> 0 AND INXSLTSTRING <>'[none]' THEN
        LXMLDATA              := DBMS_XMLGEN.GETXMLTYPE(CTX,DBMS_XMLGEN.NONE);
        LHTMLOUTPUT           :=LXMLDATA.TRANSFORM(XMLTYPE(INXSLTSTRING));
      ELSE
        xmlResult := dbms_xmlgen.getxml(ctx);
      END IF;
      DBMS_XMLGEN.CLOSECONTEXT(CTX);
      IF LENGTH(INXSLTSTRING) <> 0 AND INXSLTSTRING <>'[none]' THEN
        RETURN LHTMLOUTPUT.GETCLOBVAL();
      ELSE
        RETURN XMLRESULT;
      END IF;
    END gen_system_genexml;
    PROCEDURE PRC_GET_CF_CNS(
        inadonis IN NUMBER,
        inyear   IN NUMBER,
        INXSLT   IN CLOB,
        OUTRETURNED OUT CLOB)
    IS
      C1 SYS_REFCURSOR;
    BEGIN
      CASE INYEAR
      WHEN 2008 THEN
        OPEN C1 FOR SELECT ADONIS,
        CRIT_AA_MARKS,
        CRIT_AA_COMMENTS
      END CASE;
      OUTRETURNED :=GEN_SYSTEM_GENEXML(C1,0,10000,INXSLT);
    END PRC_GET_CF_CNS;

    (I mix my accounts, I posted with an outdated email)
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - ProductionIf I run without XLST I get (DBMSOUTPUT in SQLDevelopper) the CR/LF
    DECLARE
      INADONIS NUMBER;
      INYEAR NUMBER;
      INXSLT CLOB;
      OUTRETURNED CLOB;
    BEGIN
      INADONIS := 100858;
      INYEAR := 2010;
      INXSLT := '[none]';
      PKG_GENERAL.PRC_GET_CF_CNS(
        INADONIS => INADONIS,
        INYEAR => INYEAR,
        INXSLT => INXSLT,
        OUTRETURNED => OUTRETURNED
      DBMS_OUTPUT.PUT_LINE('OUTRETURNED = ' || OUTRETURNED);
    END;if I replace the '[none]' by the xslt string it looks, still in the dbms_output, being there...
    if I
    DBMS_OUTPUT.PUT_LINE('OUTRETURNED = ' || replace(OUTRETURNED,chr(10),'<br/>'));the result is broken...
    For the moment, I do this to avoid post-processing Cold Fusion
    FUNCTION GEN_SYSTEM_GENEXML(
        INQUERYSTRING IN SYS_REFCURSOR,
        inStartRow    IN NUMBER,
        inMaxRows     IN NUMBER,
        inXsltString  IN CLOB)
      RETURN CLOB
    AS
      LHTMLOUTPUT XMLTYPE;
      xmlResult CLOB;
      CTX DBMS_XMLGEN.CTXHANDLE;
      lXMLData XMLType;
    BEGIN
      CTX := DBMS_XMLGEN.NEWCONTEXT(INQUERYSTRING);
      dbms_xmlgen.setNullHandling(ctx, 2);
      dbms_xmlgen.setIndentationWidth(ctx, 0);
      dbms_xmlgen.setRowSetTag(ctx, 'ROOT');
      dbms_xmlgen.setRowTag(ctx, 'item');
      dbms_xmlgen.setskiprows(ctx,inStartRow);
      DBMS_XMLGEN.SETMAXROWS(CTX,INMAXROWS);
      dbms_xmlgen.setConvertSpecialChars(ctx, TRUE);
      IF LENGTH(INXSLTSTRING) <> 0 AND INXSLTSTRING <>'[none]' THEN
        LXMLDATA              := DBMS_XMLGEN.GETXMLTYPE(CTX,DBMS_XMLGEN.NONE);
        LHTMLOUTPUT           :=LXMLDATA.TRANSFORM(XMLTYPE(INXSLTSTRING));
      ELSE
        xmlResult := dbms_xmlgen.getxml(ctx);
      END IF;
      DBMS_XMLGEN.CLOSECONTEXT(CTX);
      IF LENGTH(INXSLTSTRING) <> 0 AND INXSLTSTRING <>'[none]' THEN
        RETURN replace(LHTMLOUTPUT.GETCLOBVAL(),'& l t ; br/ & g t ;','<br/>');
      ELSE
        RETURN XMLRESULT;
      END IF;
    END gen_system_genexml;& l t ; br/ & g t ; without the extract spaces
    Edited by: user4882594 on Jan 20, 2011 7:06 AM
    Edited by: user4882594 on Jan 20, 2011 7:06 AM

  • Report VS Excel output using XML Publisher tool (DBMS_XMLGEN)

    Hi All,
    Currently I am working on report generation in MRP module with Excel output using XML Publisher tool.
    XML tool works based on query.
    I have developed PLSQL block by using DBMS_XMLGEN – database package, to generate XML output of query.
    My question is how we can put generated xml on above PLSQL block into OUT file (APPS).
    Because DBMS_OUTPUT.PUT_LINE( ) has limitation, it allow 255 character string only.
    But I do not know, Is FND_FILE.PUT_LINE (FND_FILE.OUTPUT,’’) allow for large data?
    If it does not allow what will be the other solution in oracle application to resolve above problem.
    Let me know any queries regarding to this problem.
    Thanks and Regards,
    Sai Krishna @cavaya.com

    Hi Prakash,
    Thanks for the reply. We did apply the one-off patch and got rid of the problem of not viewing 'Excel' output using XMLP.
    Now we are looking at a different perspective:
    Basically our client is looking for the following:
    1. Mathematical functions in the resulting XLS (like SUM, AVG etc..) ouput
    2. Use of macros if possible.
    And to do this i am looking out for a sample template that gives me output in excel format I have a TAR with Oracle for this purpose, but the TAR has so far been unsuccessful in providing us with any material in the direction.
    Our client remembers seeing this as a demo at the Oracle Conference this yr at San Fransisco, but does not have a sample to provide us. We are looking for such a sample.
    Thx,
    Nitin

  • How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?

    How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?
    Hi,
    I do generate XML-Files by using DBMS_XMLGEN with output by UTL_FILE
    but it seems, the xml-Datafile I get on end is not really UTF-8 encoding
    ( f.ex. cannot verifying it correct in xmlspy )
    my dbms is
    NLS_CHARACTERSET          = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET     = AL16UTF16
    NLS_RDBMS_VERSION     = 10.2.0.1.0
    I do generate it in this matter :
    declare
    xmldoc CLOB;
    ctx number ;
    utl_file.file_type;
    begin
    -- generate fom xml-view :
    ctx := DBMS_XMLGEN.newContext('select xml from xml_View');
    DBMS_XMLGEN.setRowSetTag(ctx, null);
    DBMS_XMLGEN.setRowTag(ctx, null );
    DBMS_XMLGEN.SETCONVERTSPECIALCHARS(ctx,TRUE);
    -- create xml-file:
    xmldoc := DBMS_XMLGEN.getXML(ctx);
    -- put data to host-file:
    vblob_len := DBMS_LOB.getlength(xmldoc);
    DBMS_LOB.READ (xmldoc, vblob_len, 1, vBuffer);
    bHandle := utl_file.fopen(vPATH,vFileName,'W',32767);
    UTL_FILE.put_line(bHandle, vbuffer, FALSE);
    UTL_FILE.fclose(bHandle);
    end ;
    maybe while work UTL_FILE there is a change the encoding ?
    How can this solved ?
    Thank you
    Norbert
    Edited by: astramare on Feb 11, 2009 12:39 PM with database charsets

    Marco,
    I tryed to work with dbms_xslprocessor.clob2file,
    that works good,
    but what is in this matter with encoding UTF-8 ?
    in my understandig, the xmltyp created should be UTF8 (16),
    but when open the xml-file in xmlSpy as UTF-8,
    it is not well ( german caracter like Ä, Ö .. ):
    my dbms is
    NLS_CHARACTERSET = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET = AL16UTF16
    NLS_RDBMS_VERSION = 10.2.0.1.0
    -- test:
    create table nh_test ( s0 number, s1 varchar2(20) ) ;
    insert into nh_test (select 1,'hallo' from dual );
    insert into nh_test (select 2,'straße' from dual );
    insert into nh_test (select 3,'mäckie' from dual );
    insert into nh_test (select 4,'euro_€' from dual );
    commit;
    select * from nh_test ;
    S0     S1
    1     hallo
    1     hallo
    2     straße
    3     mäckie
    4     euro_€
    declare
    rc sys_refcursor;
    begin
    open rc FOR SELECT * FROM ( SELECT s0,s1 from nh_test );
    dbms_xslprocessor.clob2file( xmltype( rc ).getclobval( ) , 'XML_EXPORT_DIR','my_xml_file.xml');
    end;
    ( its the same when using output with DBMS_XMLDOM.WRITETOFILE )
    open in xmlSpy is:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <S0>1</S0>
    <S1>hallo</S1>
    </ROW>
    <ROW>
    <S0>2</S0>
    <S1>straޥ</S1>
    </ROW>
    <ROW>
    <S0>3</S0>
    <S1>m㢫ie</S1>
    </ROW>
    <ROW>
    <S0>4</S0>
    <S1>euro_€</S1>
    </ROW>
    </ROWSET>
    regards
    Norbert

  • XML File Generation Issues using DBMS_XMLGEN

    Hi,
    I am using DBMS_XMLGEN package in a stored procedure to generate an XML file on Oracle 10 G R2 .But, the problem is the format in which the file is generated.
    CREATE OR REPLACE TYPE "state_info" as object (
    "@product_type" Number
    CREATE OR REPLACE TYPE prod_tab as TABLE OF "state_info";
    CREATE OR REPLACE TYPE state_t as object (
    "state_code" CHAR(2),
    "state_info" prod_tab
    CREATE OR REPLACE PROCEDURE get_xml_serviced_state (p_clob OUT clob)
    IS
    v_xmlctx DBMS_XMLGEN.ctxhandle;
    v_str VARCHAR2 (1000);
    BEGIN
    v_str := 'SELECT state_t(a.st_cd,CAST(MULTISET(select veh_type_id from svcd_st where st_cd =a.st_cd)as prod_tab)) as "state_info"
    from svcd_st a where a.st_cd in (select distinct st_cd from svcd_st) group by a.st_cd having count(*)>=1';
    v_xmlctx := DBMS_XMLGEN.newcontext (v_str);
    DBMS_XMLGEN.setrowsettag (v_xmlctx,'serviced_state');
    DBMS_XMLGEN.setrowtag (v_xmlctx,NULL);
    p_clob := DBMS_XMLGEN.getxml (v_xmlctx);
    printclobout(p_clob);
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    RAISE;
    END;
    SHOW ERRORS
    Output :
    <serviced_state>
    <state_info state_code="VA">
    <state_info>
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    </state_info>
    <state_info state_code="AB">
    <state_info>
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    </state_info>
    </serviced_state>
    Required it in below format:
    <serviced_state>
    <state_info state_code="VA">
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    <state_info state_code="AB">
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    </serviced_state>
    I just need to put in all the rows under one single tag.Appreciate your early responses.
    Thanks.

    Your wanted XML output is NOT VALID...(try it yourself on http://tools.decisionsoft.com/schemaValidate/)

  • Date format in XML sys.dbms_xmlgen

    hello all,
    i have posted this question in "general XML " forum also....so please dont mind
    i am using following query to generate insert SQL statements
    SELECT
    'insert into ' || table_name || ' (' || (select rtrim(extract(xmlagg(xmlelement(e, t.column_value.getrootelement() || ',')),'//text()'),',') from table(xmlsequence(t.column_value.extract('ROW/*'))) t) || ') values (' ||
    (select dbms_xmlgen.convert(rtrim(extract(xmlagg(xmlelement(e, '''' || t.column_value.extract('//text()') || ''',')),'//text()'),','),1) from table(xmlsequence(t.column_value.extract('ROW/*')))t) || ');' ins_stmt
    from user_tables,
    table(xmlsequence(dbms_xmlgen.getxmltype('select * from ' || a_TblName ||' WHERE MODIFIEDON >'||a_date).extract('ROWSET/ROW'))) t
    where table_name in (select table_name from user_tables where table_name =a_TblName);but when i execute the procedure as
    sql> exec   Gen_Insert_Statement('11-jun-2009');
    ORA-19202: Error occurred in XML processing
    ORA-00904: "JUN": invalid identifier
    ORA-06512: at "SYS.DBMS_XMLGEN", line 288
    ORA-06512: at line 1
    ORA-06512: at "MRILDATA17TEST.GEN_INSERT_STATEMENT", line 22
    ORA-06512: at line 2     and if i do this
    SQL> exec Gen_Insert_Statement('11-06-2009');
    begin Gen_Insert_Statement('11-06-2009'); end;
    ORA-01843: not a valid month
    ORA-06512: at line 2is there any format to pass date while using XML packages??? i am also not getting in which this issue is occuring??
    any suggestion will be appreciable
    thanks and regards
    VD
    Edited by: dixit on Aug 13, 2009 6:15 AM

    thanks for not replying

  • Error in the dbms_xmlgen.getxmltype query

    Following query is used to search particular string in the whole database and returns the table and column name which contains that string ...Most of the time it gives the correct results but sometime it give the error as follows.Anyone please expalin whts the error is and how to solve it.
    1 select distinct table_name
    2 ,substr (t.column_value.getstringval (), 1, 50) "Column/Value"
    3 from user_tab_cols,
    4 table
    5 (xmlsequence
    6 (dbms_xmlgen.getxmltype ('select '||column_name
    7 ||' from '||table_name
    8 ||' where upper('||column_name||')=''40'''
    9 ).extract('ROWSET/ROW/*'))
    10 ) t
    11 where table_name in ('EMP','DEPT')
    12* order by 1
    SQL> /
    TABLE_NAME Column/Value
    DEPT <DEPTNO>40</DEPTNO>
    ERROR at line 6:
    ORA-19202: Error occurred in XML processing
    ORA-00932: inconsistent datatypes: expected NUMBER got BLOB
    ORA-06512: at "SYS.DBMS_XMLGEN", line 288
    ORA-06512: at line 1.......

    Jodus wrote:
    It is Number data type."o.order_ddt" is it julian date? (stored as number)
    post sample data
    also try smth
    to_date(op.order_ddt ,'mmddyyyy')

  • DBMS_XMLGEN not working for me

    I'm just starting with this, so I may be missing something.
    I have 9.2.0.1.0 installed on Linux Redhat.
    I'm trying to create an XML document by querying a table
    as described in the Oracle 9i XML Database Developer's Guide, pg 10-28.
    I'm querying a very simple table, and it seems to start, but then it creates locks and that is it. I don't get errors, it just doesn't work. Below is what I do/get:
    create table xml_test_clob (result clob);
    declare
    v_result clob;
    l_ctx dbms_xmlgen.ctxHandle;
    l_sql varchar2(400);
    begin
    l_sql := 'select * from scott.emp';
    l_ctx := dbms_xmlgen.newContext(l_sql);
    v_result := dbms_xmlgen.getXml(l_ctx);
    insert into xml_test_clob VALUES(v_result);
    dbms_output.put_line('testing');
    dbms_xmlgen.closecontext(l_ctx);
    exception
    when others then
    dbms_output.put_line('error: '||to_char(sqlcode));
    end;
    testing
    PL/SQL procedure successfully completed.
    SQL> select * from xml_test_clob;
    RESULT
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <EMPNO>7369</EMPNO>
    <ENAME>SMITH</ENAM
    SQL>
    It seems like it just stops, and then I have locks which I have to clear in order to truncate the table to try again.
    I'm just in a 'normal' schema. Do I have to do something else to make this work?
    Thanks,
    Tim

    Mark,
    Yes I did run catpatch.sql.
    when trying to compile dbms_xmlgen, I get:
    SQL> alter package dbms_xmlgen compile body;
    alter package dbms_xmlgen compile body
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-04045: errors during recompilation/revalidation of LBACSYS.LBAC_EVENTS
    ORA-06508: PL/SQL: could not find program unit being called
    ORA-06512: at line 2
    ORA-06508: PL/SQL: could not find program unit being called
    ORA-06512: at line 2
    SQL>
    I did a search on metalink and found that LBACSYS is
    'Label Security'. I don't recall selecting this to be
    installed when I first installed the db.
    I found a post on metalink that showed a script, catnools.sql that removes Label Security. Do you think
    I should run it?
    Is there some way to regenerate dbms_xmlgen (rather than
    recompile?)

  • Using dbms_xmlgen with a CAST statement

    The following code populates a plsql collection and then attempts to select from it using dbms_xmlgen.
    the following error results --
    DECLARE
    ERROR at line 1:
    ORA-19206: Invalid value for query or REF CURSOR parameter
    ORA-06512: at "SYS.DBMS_XMLGEN", line 83
    ORA-06512: at line 56
    The query is correct as the commented out select at end of block works fine.
    Can dbms_xmlgen be used in such a way and if not is there a workaround.
    Thanks
    DECLARE
    types declared on the database
    create or replace type bus_tab_obj AS object
    ( BUSINESS_MODEL_ID NUMBER(10)
    ,BUSINESS_MODEL_VER_NO NUMBER(5)
    ,BUSINESS_MODEL_NAME VARCHAR2(30));
    create or replace TYPE bus_table AS TABLE of bus_tab_obj;
    package level variable bus_table_recs in package get_values_pkg
    myxml sys.xmltype;
    queryCtx DBMS_XMLGen.ctxhandle;
    BEGIN
    -- initialise and delete
    get_values_pkg.bus_table_recs := bus_table(NULL,NULL,NULL);
    get_values_pkg.bus_table_recs.DELETE;
    -- select some records to put in the collection
    for x in ( select BUSINESS_MODEL_ID
    ,BUSINESS_MODEL_VER_NO
    ,BUSINESS_MODEL_NAME
    from BRK_BUSINESS_MODEL )
    LOOP
    get_values_pkg.bus_table_recs.extend;
    get_values_pkg.bus_table_recs := bus_table(bus_tab_obj(x.business_model_id
    ,x.business_model_ver_no
    ,x.business_model_name));
    END LOOP;
    -- retrieve the records from the collection as xml
    queryCtx := DBMS_XMLGen.newContext('select a.business_model_name data from THE ( select cast( get_values_pkg.bus_table_recs as bus_table ) from dual ) a order by data');
    dbms_xmlgen.setMaxRows(queryCtx,1);
    myxml := DBMS_XMLGen.getXMLType(queryCtx);
    dbms_output.put_line(myxml.extract('/*').getStringVal());
    this works!
    for x in ( select a.business_model_name data
    from THE ( select cast( get_values_pkg.bus_table_recs as bus_table ) from dual ) a
    order by data )
    loop
    dbms_output.put_line( x.data );
    end loop;
    END;
    /

    891794 wrote:
    Thank you all , see I am new to this database field , I am not a pro.Not a problem. However, one of the very first things you should learn is that dynamic SQL is seldom needed and invariably just plain wrong.
    If a table name is dynamic, or a column name is dynamic - then chances are excellent that your data model is already fubar'ed (or malema'ed to put it in a za.org perspective).
    And even when you are in the very exceptional situation where dynamic SQL is needed, SQL injection is a MAJOR security concern.. and almost always ignored by implementing shoddy code to create and execute the dynamic SQL.

  • Using dbms_xmlgen.getxml with new and old tables in triggers

    Is there a way to use getxml against the data stored in the new and old tables in a trigger? Simply doing this:
    Xml_Variable := dbms_xmlgen.getxml('Select * from New');
    Does not work.
    Edited by: user13302591 on Jun 16, 2010 1:16 PM

    user13302591 wrote:
    How would I pass the information from the :new and :old to getxml?What are you trying to do? You could use, for example:
    XMLELEMENT("old",:old.column_name)
    XMLELEMENT("new",:new.column_name)SY.

  • DBMS_XMLGEN --Number of active cursors in increased in Exception block

    Hi ,
    We have a custom code that use DBMS_XMLGEN,the issue is when any exception happens the Number os active cusrors increse and when it happens in a lopp we hit 1000ORA-01000: maximum open cursors exceeded.
    Although I close the context in the exception Block.
    Below is sample code where I could replicate this:
    Step1.Create a table
    CREATE TABLE EMP(EMP_NO NUMBER,EMPNAME VARCHAR2(100));
    Step2:
    Create  a Procedure:
    CREATE OR REPLACE PROCEDURE TEST_XMLGEN
    AS
    l_clob CLOB;
      l_ctx         dbms_xmlgen.ctxhandle;
      p_sql VARCHAR2(4000):='SELECT EMP_NO,,EMPNAME FROM EMP';--syntax error on purpose ,so that exception happens
      l_cursor_count NUMBER;
    BEGIN
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
            DBMS_OUTPUT.PUT_LINE ('open cursors place00' || l_cursor_count);
    l_ctx := dbms_xmlgen.newcontext (p_sql);
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
             DBMS_OUTPUT.PUT_LINE('open cursors place01' || l_cursor_count);
    dbms_xmlgen.getxml (l_ctx,l_clob);
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
             DBMS_OUTPUT.PUT_LINE ('open cursors place02' || l_cursor_count);
    DBMS_OUTPUT.PUT_LINE('l_clob:'||l_clob);
    dbms_xmlgen.closecontext (l_ctx);
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
             DBMS_OUTPUT.PUT_LINE ('open cursors place03' || l_cursor_count);
    EXCEPTION
    WHEN OTHERS
    THEN
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
             DBMS_OUTPUT.PUT_LINE ('open cursors place04' || l_cursor_count);
    dbms_xmlgen.closecontext (l_ctx);
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
             DBMS_OUTPUT.PUT_LINE ('open cursors place05' || l_cursor_count);
    END;
    Step3: Execute above Procedure
    If you look at the number of active cursor it is increased in exception block,I suspect this is what is causing issue with my program too.Any suggestions to solve this issue.
    Thanks
    Shefali

    Did you mean this test:
    declare
      ts timestamp;
      type tp_strings is table of varchar2(32767) index by pls_integer;
      t_strings tp_strings;
      t_tmp xmltype;
      t_nd dbms_xmldom.domnode;
      t_nl dbms_xmldom.domnodelist;
      t_clob clob;
    begin
      t_clob := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
             || '<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="5000" uniqueCount="5000">';
      for i in 1 .. 5000
      loop
        t_clob := t_clob || to_clob( '<si><t>A' || to_char( i ) || '</t></si>' );
      end loop;
      t_clob := t_clob || '</sst>';
      t_tmp := xmltype( t_clob );
      t_strings.delete;
      ts := systimestamp;
          select str
          bulk collect into t_strings
          from xmltable( xmlnamespaces( default 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' )
                       , '/sst/si' passing t_tmp
                       columns str clob path 't'
      dbms_output.put_line( systimestamp - ts );
      dbms_output.put_line( t_strings.count() || ' ' || t_strings( t_strings.first )  || ' ' || t_strings( t_strings.last ) );
      t_strings.delete;
      ts := systimestamp;
          select /*+ NO_XML_QUERY_REWRITE */ str
          bulk collect into t_strings
          from xmltable( xmlnamespaces( default 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' )
                       , '/sst/si' passing t_tmp
                       columns str clob path 't'
      dbms_output.put_line( systimestamp - ts );
      dbms_output.put_line( t_strings.count() || ' ' || t_strings( t_strings.first )  || ' ' || t_strings( t_strings.last ) );
      t_strings.delete;
      ts := systimestamp;
          t_nd := dbms_xmldom.makenode( dbms_xmldom.getdocumentelement( dbms_xmldom.newdomdocument( t_tmp ) ) );
          t_nl := dbms_xslprocessor.selectnodes( t_nd, '/sst/si/t/text()', 'xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"' );
          for i in 0 .. dbms_xmldom.getlength( t_nl ) - 1
          loop
            t_strings( i ) := dbms_xmldom.getnodevalue( dbms_xmldom.item( t_nl, i ) );
          end loop;
      dbms_output.put_line( systimestamp - ts );
      dbms_output.put_line( t_strings.count() || ' ' || t_strings( t_strings.first )  || ' ' || t_strings( t_strings.last ) );
    end;  

  • How to filter particular xml tag value using -DBMS_XMLGEN / DBMS_XMLSTORE

    Hi,
    I am using dbms_xmlgen and dbms_xmlstore package to extract xml datafile tag value from file server to oracle database table.
    I have used the below pl/sql program to extract the xml tag values to oracle relational table.Its working fine for me.
    But I would like to extract the values based on particular filter condition.
    The following xml program I have 3 rows I would like extract the xml data based on the following condition .
    Filter condition
    ==============
    the tag <STATE_ABBREVIATION> value shuold be 'CA' and the <CITY> tag value should be Palo_Alto then I will store the ZIPCODE
    ZIP_CODE_EXTN,STATE_ABBREVIATION tag values in the Oracle Relational table.
    The below pl/sql program storing all the three rows but I required the values based on the filter condition that I mentioned earlier.
    Kindly assist me what are the steps that I need to change in this program.?
    XML Program file content.
    ======================
    <ZIPCODES>
    <mappings>
    <STATE_ABBREVIATION>CA</STATE_ABBREVIATION>
    <ZIPCODE>94301</ZIPCODE>
    <ZIP_CODE_EXTN>9277</ZIP_CODE_EXTN>
    <CITY>Palo_Alto</CITY>
    </mappings>
    <mappings>
    <STATE_ABBREVIATION>CA</STATE_ABBREVIATION>
    <ZIPCODE>95302</ZIPCODE>
    <ZIP_CODE_EXTN>9279</ZIP_CODE_EXTN>
    <CITY>LA</CITY>
    </mappings>
    <mappings>
    <STATE_ABBREVIATION>TX</STATE_ABBREVIATION>
    <ZIPCODE>75038</ZIPCODE>
    <ZIP_CODE_EXTN>7837</ZIP_CODE_EXTN>
    <CITY>DALLAS</CITY>
    </mappings>
    </ZIPCODES>
    PL/SQL Program for XML extract.
    ==========
    declare
    charString varchar2(80);
    finalStr varchar2(4000) := null;
    rowsp number;
    insCtx DBMS_XMLStore.ctxType;
    ctx dbms_xmlgen.ctxHandle;
    v_FileHandle UTL_FILE.FILE_TYPE;
    begin
    v_FileHandle := utl_file.fopen('XMLTEST','XML_NEW_CITIES.XML','r') ;
    loop
    BEGIN
    utl_file.get_line(v_FileHandle, charString);
    exception
    when no_data_found then
    utl_file.fclose(v_FileHandle);
    exit;
    END;
    dbms_output.put_line(charString);
    if finalStr is not null then
    finalStr := finalStr || charString;
    else
    finalStr := charString;
    end if;
    end loop;
    insCtx := DBMS_XMLStore.newContext('SYS.ZIPCODES');
    dbms_xmlgen.setRowsetTag(insCtx,'ZIPCODES');
    dbms_xmlgen.setRowsetTag(insCtx,'mappings');
    DBMS_XMLStore.clearUpdateColumnList(insCtx);
    DBMS_XMLStore.setUpdateColumn(insCtx,'ZIPCODE');
    DBMS_XMLStore.setUpdateColumn(insCtx,'ZIP_CODE_EXT N');
    DBMS_XMLStore.setUpdateColumn(insCtx,'STATE_ABBREV IATION');
    rowsp := dbms_xmlstore.insertXML(insCtx,finalstr);
    end;
    Thanks,
    nat

    Thanks for your reply. :)
    Its working fine in the DBMS_XMLSTORE package. Here I have given the code
    CREATE OR REPLACE TYPE typ_dummy AS  OBJECT
    ( "@ENO"   NUMBER,
      "@ENAME" VARCHAR2(100),
      eno      NUMBER,
      ename    VARCHAR2(100));
    CREATE TABLE EMP
      empno    VARCHAR2(25),
      sal      NUMBER,
      hiredate DATE,
      typ      TYP_DUMMY
    DECLARE
      insCtx DBMS_XMLStore.ctxType;
      rows NUMBER;
      xmldoc CLOB :=
        '<ROWSET>
           <ROW num="1">
             <SAL>1800</SAL>
             <EMPNO>739</EMPNO>
             <HIREDATE>27-AUG-1996</HIREDATE>
               <TYP ENO="739" ENAME="Nazurullah">
               <ENO> 1 </ENO>
               <ENAME> ALDRIN </ENAME>
               </TYP>
           </ROW>
           <ROW>
             <SAL>18000</SAL>
             <EMPNO>7369</EMPNO>
             <HIREDATE>27-AUG-1996</HIREDATE>
             <TYP ENO="7369" ENAME="PEPPIN" />
           </ROW>
           <ROW>
             <SAL>37000</SAL>
             <EMPNO>20701</EMPNO>
             <HIREDATE>27-AUG-1996</HIREDATE>
             <TYP>
               <ENO> 20701 </ENO>
               <ENAME> VENKATACHALAM </ENAME>
             </TYP>
           </ROW>
         </ROWSET>';
    BEGIN
      insCtx := DBMS_XMLStore.newContext('emp'); -- get saved context
      -- Now insert the doc.
      -- This will only insert into EMPNO, SAL and HIREDATE columns
      rows := DBMS_XMLStore.insertXML(insCtx, xmlDoc);
      -- Close the context
      DBMS_XMLStore.closeContext(insCtx);
    END;
    SELECT * FROM emp;
    EMPNO        SAL HIREDATE          TYP(@ENO, @ENAME, ENO, ENAME)
    739         1800 27-AUG-96     TYP_DUMMY(739, 'Nazurullah', 1, ' ALDRIN ')
    7369       18000 27-AUG-96     TYP_DUMMY(7369, 'PEPPIN', NULL, NULL)
    20701      37000 27-AUG-96     TYP_DUMMY(NULL, NULL, 20701, ' VENKATACHALAM ')

  • Dbms_xmlgen using pl-sql record type

    Hi
    I want to pass pl-sql record type and want to generate xml. Can dbms_xmlgen access pl-sql record type instead of query?
    OR please let me know any other package to pass pl-sql record type and generate XML.
    Thanks in advance

    Can dbms_xmlgen access pl-sql record type instead of query?Don't think so, but can't you pass the individual record components:
    SQL> declare
      type rec is record
        a   int,
        b   varchar2 (30)
      r     rec;
      ctx   int;
      x     xmltype;
    begin
      r.a := 1;
      r.b := 'Michael';
      ctx := dbms_xmlgen.newcontext ('select :x id, :y name from dual');
      dbms_xmlgen.setbindvalue (ctx, 'x', r.a);
      dbms_xmlgen.setbindvalue (ctx, 'y', r.b);
      x := dbms_xmlgen.getxmltype (ctx);
      dbms_output.put_line (x.getstringval ());
      dbms_xmlgen.closecontext (ctx);
    end;
    <ROWSET>
    <ROW>
      <ID>1</ID>
      <NAME>Michael</NAME>
    </ROW>
    </ROWSET>
    PL/SQL procedure successfully completed.?

Maybe you are looking for