Writing DOMDocument to clob

Maybe I've missed something obvious but I can't get the XML stuff to work.
I've got a table with CLOBs containing XML text. I would like to use a proc to alter the XML and store it in another CLOB.
So:
DECLARE
v_source CLOB;
v_document XMLType;
v_dom_doc dbms_xmldom.DOMDocument;
v_result CLOB;
myParser dbms_xmlparser.Parser;
BEGIN
v_result := EMPTY_CLOB();
SELECT content INTO v_source
FROM user_content WHERE id = 1;
myParser := dbms_xmlparser.newParser;
dbms_xmlparser.setValidationMode(myParser, FALSE);
dbms_xmlparser.parseClob(myParser, v_source);
v_dom_doc := dbms_xmlparser.getDocument(myParser);
dbms_xmldom.writeToClob(v_dom_doc, v_result);
commit;
END;
This fails like this:
ERROR at line 1:
ORA-00600: internal error code, arguments: [kghsccread1], [18805], [18804], [],
ORA-06512: at "XDB.DBMS_XMLDOM", line 3734
ORA-06512: at "XDB.DBMS_XMLDOM", line 3752
ORA-06512: at line 15
I can't see anything wrong with it.Can anyone give me a clue?
Thanks.
Nic Ferrier

The documents I'm using seem to fail erratically (I've put an example at the end of the post).
The parser seems to be broken as regards tabs at the beginning of a line, but it also seems to be broken in other ways.
I tried to parse the document below and it works as long as the <test> root element no longer wraps the <precedent> element. When you put the <test> element in the parser fails when there are TABs at the start of certain lines.
It makes me VERY unconfident about the PL/SQL parser.
Here's my example document (but the tabs are probably dropped):
<?xml version="1.0"?>
<test>
<precedent-intro>
<title>Drafting Guide</title>
<para-text>This is a lease for a lock-up shop within a modern shopping centre, which would be on standard terms. The landlord provides services to the shop and more widely for the visitors to the centre. The tenant pays a service charge which contributes to the cost of all the services. An unusual provision is the landlord&apos;s obligation to consult all the centre&apos;s tenants about the opening hours, services and advertising.</para-text>
<para-text>The lease provides that the landlord has no continuing liability after parting with its interest in the premises, but the landlord covenants not to assign its interest in part only of centre. Without an express provision about continuing liability, the landlord is only released by serving notice on the tenant. That gives the tenant the opportunity to apply to the court to object (<legis-cite type='statute' id='1033194357' locsrc='1033193166' title='Landlord and Tenant (Covenants) Act' date='1995' docid='a1995c30' dbid='master' validated='yes'>
<legis-name href='root'>Landlord and Tenant (Covenants) Act 1995</legis-name>
, <legis-ref href='s6'>ss. 6</legis-ref>
, <legis-ref href='s8'>8</legis-ref>
</legis-cite>
). However, if the landlord assigned its interest in part of the centre, it would no longer be liable on its covenants relating to that part. That could make the provisions about services unworkable. See <emphasis type='normal'>Leasehold Law</emphasis>
, para. 1.016.</para-text>
<para-text>The tenant is free to dispose of the lease, with consent which the landlord is not entitled to withhold unreasonably, but is not entitled to sub-let part only of the unit. This preserves the intended subdivision of the centre and then prevents the situation at the end of the lease where a sub-tenant of part only of the unit is entitled to a statutory renewal of the lease of that part, so that the landlord finds itself obliged to let a divided property to more than one tenant (<legis-cite type='statute' id='1033194394' locsrc='1033193101' title='Landlord and Tenant Act' date='1954' docid='a1954(2&amp;3Eliz2)c56' dbid='master' validated='yes'>
<legis-name href='root'>Landlord and Tenant Act 1954</legis-name>
, <legis-ref href='s23'>s. 23</legis-ref>
, <legis-ref href='sch6'>Sched. 6</legis-ref>
</legis-cite>
; although if the head tenant applies to renew the lease of part of the premises, he can be obliged to take a new lease of the whole: <emphasis type='normal'>ibid.</emphasis>
<legis-cite type='statute' id='1033200923' locsrc='1033193101' title='Landlord and Tenant Act' date='1954' docid='a1954(2&amp;3Eliz2)c56' dbid='master' validated='yes'>
<legis-ref href='s32(2)'>s. 32(2)</legis-ref>
</legis-cite>
). See <emphasis type='normal'>Leasehold Law</emphasis>
, paras 4.285, 5.047.</para-text>
<para-text>On an assignment of the lease, the landlord can require the assignor to enter into an authorised guarantee agreement so that he continues to have responsibility for the performance of the lease covenants until the lease is further assigned (<legis-cite type='statute' id='1033194441' locsrc='1033193166' title='Landlord and Tenant (Covenants) Act' date='1995' docid='a1995c30' dbid='master' validated='yes'>
<legis-name href='root'>Landlord and Tenant (Covenants) Act 1995</legis-name>
, <legis-ref href='s16'>s. 16</legis-ref>
</legis-cite>
). See <emphasis type='normal'>Leasehold Law</emphasis>
, para. 4.330.</para-text>
<para-text>The tenant covenants to keep the premises open for business during the centre&apos;s general opening hours. The landlord will not be able to obtain an order of specific performance to enforce this (<case-cite type='ukcase' id='1033194450' locsrc='new' party1='Cooperative Insurance Society Ltd' party2='Argyll Stores (Holdings) Ltd' reference='[1998] A.C. 1' validated='yes' dbid='master'>
<casename italic='1'>
<party1>Cooperative Insurance Society Ltd</party1>
v. <party2>Argyll Stores (Holdings) Ltd</party2>
</casename>
<case-ref>[1998] A.C. 1</case-ref>
</case-cite>
). See <emphasis type='normal'>Leasehold Law</emphasis>
, para. 7.013.</para-text>
<para-text>The rent review is on an upward only basis. See <emphasis type='normal'>Leasehold Law</emphasis>
, para. 4.049. Another type of rent review clause can be substituted. The tenant covenants to keep the details of any rent review confidential. Although this may be commercially important for the landlord, there might be difficulties in enforcing the covenant.</para-text>
<para-text>The form assumes that guarantor(s) will guarantee the performance of the tenant&apos;s obligations. It also gives the landlord the option to require that the guarantor(s) take a new lease for the remainder of the term if the landlord forfeits current one. This extends the normal liability of a guarantor which would end on forfeiture. Because the original tenant&apos;s liability ends on assignment, subject only to the effect of any authorised guarantee agreement, his guarantor&apos;s liability is similarly limited. The landlord&apos;s position is therefore strengthened by a clause allowing it to withhold consent to an assignment unless a suitable guarantor guarantees the assignee&apos;s covenants.</para-text>
<para-text>The landlord covenants to comply with the terms of the head lease, so far as the sub-lease does not place the obligations on the subtenant. This is important for the sub-tenant, because the sub-lease comes to an end if the head lease is forfeited, subject to a right of relief (<legis-cite type='statute' id='1033194476' locsrc='1033194171' title='Law of Property Act' date='1925' docid='a1925(15&amp;16Geo5)c20' dbid='master' validated='yes'>
<legis-name href='root'>Law of Property Act 1925</legis-name>
, <legis-ref href='s146(4)'>s. 146(4)</legis-ref>
</legis-cite>
). See <emphasis type='normal'>Leasehold Law</emphasis>
, para. 6.075.</para-text>
<para-text>Any dispute under the lease is to be referred to arbitration. See <emphasis type='normal'>Leasehold Law</emphasis>
, para. 7.133.</para-text>
</precedent-intro>
</test>

Similar Messages

  • Writing and retreiving clob

    I have written an xsl page which is very long (about 6k) and I think to store it in a table in a clob field so that I could retreive it later to apply to my xml page by using dbms_xmlquery.setxslt(queryctx,xslt_clob);
    I am trying to insert xsl page directly into a table like this:
    create table temp_table(xslt_clob clob);
    insert into temp_table(xslt_clob) values (
    '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <MainTag>
    </MainTag>
    When I do that I get an error:
    ORA-01704: string literal too long
    Are there any other ways to insert clob into and retreive it from a table?
    Thanx.

    I didn't see the fix for this posted, and I was running into the same thing.
    After trying to run the INSERT directly, I wound up creating a PL/SQL procedure to do the work. Once I did that it still wouldn't work and after some consultation with one of our DBA's he was able to get it to work. Then he went on to explain that SQLPlus has a problem with >4 or >6K for inserts's even though the CLOB is quite a bit larger so you have to create a procedure or package.
    CREATE OR REPLACE PROCEDURE Loadxmlstylesheet IS
    poXML CLOB;
    BEGIN
    poXML := '<?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet VERSION="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="env xs">
         <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template>...</xsl:template>
    </xsl:stylesheet>';
    INSERT INTO xml_stylesheets
    VALUES (1, 'DBQueryToXMLOut', XMLTYPE(poXML));
    COMMIT;
    --Handle the exceptions
    EXCEPTION
    WHEN OTHERS THEN
         Pkg_Errorhandler.savemsg (p_code => SQLCODE,
    p_severity => 'F',
    p_message => SUBSTR (SQLERRM, 1, 900),
    p_src_name => 'loadXMLStylesheet',
    p_application_id => 'loadXMLStylesheet'
    END Loadxmlstylesheet;
    /

  • Weblogic 8.1/Oracle 9 Writing and Reading Clob

    I’m trying to write and read a clob to a database table. The database table has
    an Id field (int) and a Content field (clob).
    My environment consists of Weblogic 8.1, and Oracle 9. Is there a way to get a
    handle to a Weblogic connection to Oracle and then write and read clobs?
    Any help would be greatly appreciated!
    Thanks,
    Mike

    Problem 1. US7ASCII and Linux - Status Resolved.
    The issue with the BEA 817 JDBC driver not connecting to the US7ASCII database tuned out to be that it had not deployed the connection pool correctly from the weblogic admin console... or that it was reported as being deployed when in fact it was not. After re-deploying the connection pool and restarting the server we were able to connect.
    The patch was for character sets was not needed.
    Problem 2. Oracle Stored Proc error.
    The problem with the stored procedures tunred out to be with ref cursors. A patch in sp3, and a change to the way we called the stored proc allowed us to fix the problem.
    The problem is reproduced when connecting to an Oracle 8.1.7 server.
    It was introduced in the Connect JDBC driver build 3.0.0007. According
    to the jdbcread.me file which comes with the 3.0.0007 build we
    deprecated the refCursorSupport connection property. This could be
    related to the driver not being able to execute a stored procedure
    containing ref cursors.
    Resolution
    Driver was fixed in the Connect JDBC 3.1 Oracle driver version 3.1.0008
    The trick was to use
    "{call PROC(?,?)}"
    instead of
    "BEGIN PROC(?, ?);
    END;"
    Here is a very useful link on the matter:
    http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=b860627b.0405130528.4db317a0%40posting.google.com&rnum=1&prev=/groups%3Fq%3D%255BBEA%255D%255BOracle%2BJDBC%2BDriver%255DInvalid%2Bparameter%2Bbinding%26hl%3Den%26lr%3D%26ie%3DUTF-8%26selm%3Db860 27b.0405130528.4db317a0%2540posting.google.com%26rnum%3D1
    The bea type 4 is an oem from DataDirect
    http://knowledgebase2.datadirect.com/kbase.nsf/26536a530e20a22b85256e550079afc2/b3be8f8fcb7c30c285256c9f006f8645?OpenDocument&Highlight=0,oracle

  • Error While Writing DOM to a CLOB i.e. xmldom.writeToClob

    I am running into error while writng and reading from a clob. The Sample Code is as follows :
    declare
    p xmlparser.Parser;
    doc xmldom.DOMDocument;
    i_tmp CLOB;
    i_tmp1 CLOB;
    i_buffer varchar2(32767);
    i_amount pls_integer;
    begin
    p := xmlParser.NewParser;
    xmlparser.setbaseDir(p,'/sqlcom/inbound');
    xmlparser.setValidationMode(p, TRUE);
    xmlparser.showwarnings(p, TRUE);
    xmlparser.seterrorlog(p, '/sqlcom/inbound/veshaal.err');
    xmlparser.parse(p,'/sqlcom/inbound/mpoi.xml');
    doc := xmlparser.getDocument(p);
    dbms_lob.createtemporary(i_tmp1,true,dbms_lob.session);
    xmldom.writeToClob(doc,i_tmp1);
    xmldom.writeToFile(doc,'/sqlcom/inbound/veshaal_out.xml');
    dbms_lob.createtemporary(i_tmp,true,dbms_lob.session);
    xmldom.writeTobuffer(doc,i_buffer);
    dbms_lob.write(i_tmp,length(i_buffer),1,i_buffer);
    i_amount := dbms_lob.getLength(i_tmp);
    dbms_lob.read(i_tmp,i_amount,1,i_buffer);
    dbms_lob.freetemporary(i_tmp1);
    commit;
    exception
    when others then
    dbms_lob.freetemporary(i_tmp1);
    dbms_output.put_line(SQLERRM);
    end;
    The oracle Error is as follows:
    declare
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    ORA-24323: value not allowed
    Error accessing package DBMS_APPLICATION_INFO
    ERROR:
    ORA-03114: not connected to ORACLE
    The above code works while I try to write to a buffer or a file using xmldom.writeToFile or xmldom.writeToBuffer.
    The xmlparser v2 is running inside the 8i ( 8.1.5.0. ) database.
    The alert file has the following entry :
    Errors in file /home/applrt/db/superbwl/log/superbwl_ora_2371.trc:
    ORA-07445: exception encountered: core dump [EE1F05DC] [SIGSEGV] [Address not mapped to object] [0] [] []
    Any help will be appreciated.
    Thanks
    null

    UTL_FILE comes as part of the database, you shouldn't have to install it, and you most certainly shouldn't install it as SCOTT. System packages should be installed using a system user such as sys.
    Firstly, I would suggest dropping the UTL_FILE package from your scott schema and then logging on as sys and granting execute permission on UTL_FILE to the scott user.
    Secondly...
    The UTL_FILE_DIR parameter has been deprecated by oracle in favour of direcory objects because of it's security problems.
    The correct thing to do is to create a directory object e.g.:
    CREATE OR REPLACE DIRECTORY mydir AS 'c:\myfiles';Note: This does not create the directory on the file system. You have to do that yourself and ensure that oracle has permission to read/write to that file system directory.
    Then, grant permission to the users who require access e.g....
    GRANT READ,WRITE ON DIRECTORY mydir TO myuser;Then use that directory object inside your FOPEN statement e.g.
    fh := UTL_FILE.FOPEN('MYDIR', 'myfile.txt', 'r');Note: You MUST specify the directory object name in quotes and in UPPER case for this to work as it is a string that is referring to a database object name which will have been stored in uppercase by default.

  • [OCI] - Select statement on Clob doesn't return the full column's content.

    Hi All,
    I'm actually working on a application using OCI on an Oracle 11gr2. The Oracle client as the 11.2.0 version, was fully(admin) installed and configured with the same NLS_LANG variable as the DB.
    In the Database, we are using CLOB to store long text files. The setup our application was writing the initial CLOB correctly, but we cant read it, we just a part of the text.
    I checked it in SQLPlus and SQLDeveloper :
    select sourcecode from script where name like 'callback';
    result :
    SOURCECODE
    // #import "CallbackFctLib"
    * Benutzerdefinierte Funktionen bei der
    if I set the long to 1000 before the Select statement, then the full file is displayed.
    set long 1000;
    select sourcecode from script where name like 'callback';
    So, this works for SQLPlus and SQLDeveloper but how can I set it for the whole System? is ist possible? does any parameters have to be pass to the "sourcecode" column to define any format?
    thanks for reading...

    Hi!
    When you establish connection to database, try explicitly give instructions about what encoding use your DB, e.g.:
    // connection properties
    Properties connInfo = new Properties();
    connInfo.put("user", username);
    connInfo.put("password", password);
    connInfo.put("charSet", "Cp1251"); // enter your codepage!!!
    // getconnection
    Connection db = DriverManager.getConnection(dataurl, connInfo);

  • Problem inserting clob value into xmltype column

    Hi all,
    I have created a table in XML DB using as:
    CREATE TABLE TransDetailstblCLOB ( id number, data_xml XMLType) XmlType data_xml STORE AS CLOB;
    I am trying to insert large xml data into the data_xml column which is of type XMLTYPE.
    I followed this link (http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/HowToLoadLargeXML.html) to create a clob object and insert into xml.
    I am getting the following error:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00229: input source is empty
    Error at line 0
    ORA-06512: at "SYS.XMLTYPE", line 254
    ORA-06512: at line 1
    My code snippet:
    private static CLOB getCLOB(String xmlData, Connection conn) throws SQLException{
         CLOB tempClob = null;
         if(conn==null){
              log.debug("Connection object is null");
              throw new SQLException("Connection object is null");
         try{
         // If the temporary CLOB has not yet been created, create new
         tempClob = CLOB.createTemporary(conn, true, CLOB.MODE_READWRITE);
         // Open the temporary CLOB in readwrite mode to enable writing
         tempClob.open(CLOB.MODE_READWRITE);
         // Get the output stream to write
         writer = tempClob.getCharacterOutputStream();
         writer.write(xmlData);
         } catch(SQLException sqlexp){
              tempClob.freeTemporary();
         sqlexp.printStackTrace();
         } catch(Exception exp){
         tempClob.freeTemporary();
         exp.printStackTrace();
         return tempClob;      
    public static void insertXML(String xmlData, Connection conn){
         CLOB clob = null;
         String query;
         log.debug("Inside insertXML" +xmlData);
         try{
         query = "INSERT INTO TransDetailstbl1(data) VALUES (XMLType(?)) ";// Changed prev TransDetailstbl
         // Get the statement Object
         pstmt = conn.prepareStatement(query);
         //      xmlData is the string that contains the XML Data.
         // Get the CLOB object using the getCLOB method.
         clob = getCLOB(xmlData, conn);
         // Bind this CLOB with the prepared Statement
         pstmt.setObject(1, clob);
         int i =pstmt.executeUpdate();
         log.debug("pstmt.executeUpdate () status ::: "+i);
         // Execute the Prepared Statement
         if (i == 1) {
         log.debug("Record Successfully inserted!");
         } catch(SQLException sqlexp){
         sqlexp.printStackTrace();
         } catch(Exception exp){
         exp.printStackTrace();
         finally{
              try{
                   pstmt.close();
    //           Flush and close the stream
                   writer.flush();
                   writer.close();
              // Close the temporary CLOB
              tempClob.close();
              catch(Exception e)
                   log.debug("Cant close prepared statement.");
                   e.printStackTrace();
    Can anyone help me out?
    Please let me know if any other info is required.
    Regards,
    Robina

    Hi all,
    I now modified the code to write the data using Stream.
    I am getting this error message: SQLException while updateORA-24813: cannot send or receive an unsupported LOB
    On googling it seems the its usually caused when I am using the different versions of oracle on
    server and client.
    My oracle details:
    Database product version : Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    JDBC driver name : Oracle JDBC driver
    JDBC driver version : 9.2.0.1.0
    DataStoreHelper name is: com.ibm.websphere.rsadapter.OracleDataStoreHelper@22542254.
    JDBC driver type : thin
    Can anyone tell me how to proceed?
    Thanks

  • NullPointer when calling CLOB.createTemporary()

    Hi all,
    I am trying to insert an xml of size more than 4k into an xml type table. Given below is the code i am using to create the CLOB to insert the same.
    I am getting a NullPointerException while creating the CLOB.
    Please help me out here!!
    CODE
    private CLOB getCLOB(String xmlData, Connection conn) throws SQLException {
              CLOB tempClob = null;
              try {
                   System.out.println("xml : ### : " + xmlData);
                   // If the temporary CLOB has not yet been created, create new
                   tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_CALL);
                   // Open the temporary CLOB in readwrite mode to enable writing
                   tempClob.open(CLOB.MODE_READWRITE);
                   // Get the output stream to write
                   Writer tempClobWriter = tempClob.getCharacterOutputStream();
                   // Write the data into the temporary CLOB
                   tempClobWriter.write(xmlData);
                   // Flush and close the stream
                   tempClobWriter.flush();
                   tempClobWriter.close();
                   // Close the temporary CLOB
                   tempClob.close();
              } catch (SQLException sqlexp) {
                   // tempClob.freeTemporary();
                   sqlexp.printStackTrace();
              } catch (Exception exp) {
                   // tempClob.freeTemporary();
                   exp.printStackTrace();
              return tempClob;
    STACK TRACE
    java.lang.NullPointerException
         at oracle.sql.LobPlsqlUtil.plsql_createTemporaryLob(LobPlsqlUtil.java:1354)
         at oracle.jdbc.dbaccess.DBAccess.createTemporaryLob(DBAccess.java:997)
         at oracle.sql.LobDBAccessImpl.createTemporaryClob(LobDBAccessImpl.java:240)
         at oracle.sql.CLOB.createTemporary(CLOB.java:527)
         at com.cx.hcm.ams.slatingms.impl.dao.SlatingDAOImpl.getCLOB(SlatingDAOImpl.java:1359)
         at com.cx.hcm.ams.slatingms.impl.dao.SlatingDAOImpl.insertXML(SlatingDAOImpl.java:1327)
         at com.cx.hcm.ams.slatingms.impl.ejb.SlatingMgmtSessionBean.insertXML(SlatingMgmtSessionBean.java:855)
         at SlatingMgmtRemote_StatelessSessionBeanWrapper16.insertXML(SlatingMgmtRemote_StatelessSessionBeanWrapper16.java:3782)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:536)

    Hi all,
    I am trying to insert an xml of size more than 4k into an xml type table. Given below is the code i am using to create the CLOB to insert the same.
    I am getting a NullPointerException while creating the CLOB.
    Please help me out here!!
    CODE
    private CLOB getCLOB(String xmlData, Connection conn) throws SQLException {
              CLOB tempClob = null;
              try {
                   System.out.println("xml : ### : " + xmlData);
                   // If the temporary CLOB has not yet been created, create new
                   tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_CALL);
                   // Open the temporary CLOB in readwrite mode to enable writing
                   tempClob.open(CLOB.MODE_READWRITE);
                   // Get the output stream to write
                   Writer tempClobWriter = tempClob.getCharacterOutputStream();
                   // Write the data into the temporary CLOB
                   tempClobWriter.write(xmlData);
                   // Flush and close the stream
                   tempClobWriter.flush();
                   tempClobWriter.close();
                   // Close the temporary CLOB
                   tempClob.close();
              } catch (SQLException sqlexp) {
                   // tempClob.freeTemporary();
                   sqlexp.printStackTrace();
              } catch (Exception exp) {
                   // tempClob.freeTemporary();
                   exp.printStackTrace();
              return tempClob;
    STACK TRACE
    java.lang.NullPointerException
         at oracle.sql.LobPlsqlUtil.plsql_createTemporaryLob(LobPlsqlUtil.java:1354)
         at oracle.jdbc.dbaccess.DBAccess.createTemporaryLob(DBAccess.java:997)
         at oracle.sql.LobDBAccessImpl.createTemporaryClob(LobDBAccessImpl.java:240)
         at oracle.sql.CLOB.createTemporary(CLOB.java:527)
         at com.cx.hcm.ams.slatingms.impl.dao.SlatingDAOImpl.getCLOB(SlatingDAOImpl.java:1359)
         at com.cx.hcm.ams.slatingms.impl.dao.SlatingDAOImpl.insertXML(SlatingDAOImpl.java:1327)
         at com.cx.hcm.ams.slatingms.impl.ejb.SlatingMgmtSessionBean.insertXML(SlatingMgmtSessionBean.java:855)
         at SlatingMgmtRemote_StatelessSessionBeanWrapper16.insertXML(SlatingMgmtRemote_StatelessSessionBeanWrapper16.java:3782)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:536)

  • Unable to write CLOB value larger then approx. 97KB

    Hello,
    I am writing the CLOB value using the java JDBC bridge (9.0.1) to the DB (8.1.6). I managed to write CLOB values ok, but when I try to write text larger then 97KB it throws the following error:
    java.io.IOException: ORA-00600: kód vnitønà chyby (internal error code in english), argumenty: [kdlseek-kgbtnscb], [], [], [], [], [], [], []
    ORA-06512: na "SYS.DBMS_LOB", line 708
    ORA-06512: na line 1
    at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBError.java:618)
    at oracle.jdbc.driver.OracleClobWriter.flushBuffer(OracleClobWriter.java:201)
    at oracle.jdbc.driver.OracleClobWriter.flush(OracleClobWriter.java:161)
    at com.trask.edoceo.sql.OracleConnection$OraclePreparedStatement.getCLOB(OracleConnection.java:103)
    at com.trask.edoceo.sql.OracleConnection$OraclePreparedStatement.setCharacterStream(OracleConnection.java:85)
    at ...
    I use the Prepared statement function setClob and for writing I create the CLOB object using the following method:
    private CLOB getCLOB(String text, Connection conn) throws SQLException {
    CLOB tempClob = null;
    try {
    // If the temporary CLOB has not yet been created, create new
    tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    // Open the temporary CLOB in readwrite mode to enable writing
    tempClob.open(CLOB.MODE_READWRITE);
                        // Get the output stream to write
    Writer tempClobWriter = tempClob.getCharacterOutputStream();
    // Write the data into the temporary CLOB
    tempClobWriter.write(text);
    // Flush and close the stream
    tempClobWriter.flush();
    tempClobWriter.close();
    // Close the temporary CLOB
    tempClob.close();
    } catch (SQLException sqlexp) {
    tempClob.freeTemporary();
    sqlexp.printStackTrace();
    } catch (Exception exp) {
    tempClob.freeTemporary();
    exp.printStackTrace();
    return tempClob;
    Under the 97KB boundary everything works fine. Is the limit hidden in the JDBC drivers (I tried the newer drivers, but they throw the END OF TNS DATA CHANNEL error) or somewhere in the oracle DB settings?
    I am using JDK 1.3.1 Win2000 and the oracle DB resides on another machine then the application.
    I tried to append the error dump from the DB, but it has 1.5MB of text :-(
    Thanks for your help.
    Jan Antos.
    [email protected]

    This forum is meant for discussions about OTN content/site and services.
    Questions about Oracle products and technologies will NOT be answered in this forum. Please post your product or technology related questions in the appropriate product or technology forums, which are monitored by Oracle product managers.
    Product forums:
    http://forums.oracle.com/forums/index.jsp?cat=9
    Technology forums:
    http://forums.oracle.com/forums/index.jsp?cat=10
    As a general guideline, please first search the forum to see if your question is already answered. You will find answers for the most frequently asked questions by simply searching the forum. This will help you to find the answer right away and will save time for all of us.

  • How to write to a CLOB

    Hi ;
    I am having a hasrd time writing to a CLOB, can you give me some advise??
    Thanks..
    Here is what I am trying to do:
    I have a xml string
    <xml>
    </xml>
    I want to write this string into a CLOB, I amdoing the following:
    len := LENGTH(xmlin);
    sys.dbms_lob.write(clob_item , len , 0, xmlin );
    What am I doing wrong???
    null

    the offset starts at 1, not 0. try:
    sys.dbms_lob.write(clob_item , len , 1, xmlin );

  • Creating a PL/SQL table based on XML file.

    I have created two procedures to try and achieve the problem at hand.
    It retrieves and displays the record from a DBMS_OUTPUT.PUT_LINE prospective as indicated in (1&2), but I am having difficulty loading these values into a PL/SQL table from the package labeled as (3).
    All code compiles. (1&2) work together, (3) works by itself but will not populate the table, and I get no errors.
    1.The first being the one that retrieves the XML file and parses it.
    CREATE OR REPLACE procedure xml_main is
    P XMLPARSER.Parser;
    DOC CLOB;
    v_xmldoc xmldom.DOMDocument;
    v_out CLOB;
    BEGIN
    P := xmlparser.newParser;
    xmlparser.setValidationMode(p, FALSE);
    DOC := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <com.welligent.Student.BasicStudent.Create>
    <ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" messagePriority="1" messageType="Sync">
    <Sender>
    <MessageId>
    <SenderAppId>com.openii.SyncRouter</SenderAppId>
    <ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
    <MessageSeq>53</MessageSeq>
    </MessageId>
    <Authentication>
    <AuthUserId>Router</AuthUserId>
    </Authentication>
    </Sender>
    <Datetime>
    <Year>2001</Year>
    <Month>3</Month>
    <Day>23</Day>
    <Hour>13</Hour>
    <Minute>47</Minute>
    <Second>30</Second>
    <SubSecond>223</SubSecond>
    <Timezone>6:00-GMT</Timezone>
    </Datetime>
    </ControlAreaSync>
    <DataArea>
    <NewData>
    <BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
    <StudentNumber>052589F201</StudentNumber>
    <ExternalIdNumber>1234567890</ExternalIdNumber>
    <StateIdNumber>123456</StateIdNumber>
    <Name>
    <LastName>Lopez</LastName>
    <FirstName>Maria</FirstName>
    <MiddleName>S</MiddleName>
    </Name>
    <Gender>Female</Gender>
    <BirthDate>
    <Month>1</Month>
    <Day>1</Day>
    <Year>1995</Year>
    </BirthDate>
    <Race>Hispanic</Race>
    <Ethnicity>Hispanic</Ethnicity>
    <PrimaryLanguage>English</PrimaryLanguage>
    <HouseholdLanguage>Spanish</HouseholdLanguage>
    <Address>
    <Street>123 Any Street</Street>
    <ApartmentNumber>12-D</ApartmentNumber>
    <City>Los Angeles</City>
    <County>Los Angeles</County>
    <State>CA</State>
    <ZipCode>90071</ZipCode>
    </Address>
    </BasicStudent>
    </NewData>
    </DataArea>
    </com.welligent.Student.BasicStudent.Create>';
    --v_out  := DOC;
    SYS.XMLPARSER.PARSECLOB ( P, DOC );
    v_xmldoc := SYS.XMLPARSER.getDocument(P);
    --DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION);
    --v_out := SYS.XMLPARSER.PARSECLOB ( P, DOC );
    --SYS.XMLDOM.writetoCLOB(v_xmldoc, v_out);
    --INSERT INTO TEST (TEST_COLUMN)
    --VALUES(V_OUT);
    --printElements(v_xmldoc);
    printElementAttributes(v_xmldoc);
    exception
    when xmldom.INDEX_SIZE_ERR then
    raise_application_error(-20120, 'Index Size error');
    when xmldom.DOMSTRING_SIZE_ERR then
    raise_application_error(-20120, 'String Size error');
    when xmldom.HIERARCHY_REQUEST_ERR then
    raise_application_error(-20120, 'Hierarchy request error');
    when xmldom.WRONG_DOCUMENT_ERR then
    raise_application_error(-20120, 'Wrong doc error');
    when xmldom.INVALID_CHARACTER_ERR then
    raise_application_error(-20120, 'Invalid Char error');
    when xmldom.NO_DATA_ALLOWED_ERR then
    raise_application_error(-20120, 'Nod data allowed error');
    when xmldom.NO_MODIFICATION_ALLOWED_ERR then
    raise_application_error(-20120, 'No mod allowed error');
    when xmldom.NOT_FOUND_ERR then
    raise_application_error(-20120, 'Not found error');
    when xmldom.NOT_SUPPORTED_ERR then
    raise_application_error(-20120, 'Not supported error');
    when xmldom.INUSE_ATTRIBUTE_ERR then
    raise_application_error(-20120, 'In use attr error');
    END;
    2. The second which displays the values from the .xml file I initialized above.
    CREATE OR REPLACE procedure printElementAttributes(doc xmldom.DOMDocument) is
    nl XMLDOM.DOMNODELIST;
    len1           NUMBER;
    len2 NUMBER;
    n      XMLDOM.DOMNODE;
    e      XMLDOM.DOMELEMENT;
    nnm      XMLDOM.DOMNAMEDNODEMAP;
    attrname VARCHAR2(100);
    attrval VARCHAR2(100);
    text_value VARCHAR2(100):=NULL;
    n_child XMLDOM.DOMNODE;
    BEGIN
    -- get all elements
    nl := XMLDOM.getElementsByTagName(doc, '*');
    len1 := XMLDOM.getLength(nl);
    -- loop through elements
    FOR j in 0..len1-1 LOOP
    n := XMLDOM.item(nl, j);
    e := XMLDOM.makeElement(n);
    DBMS_OUTPUT.PUT_LINE(xmldom.getTagName(e) || ':');
    -- get all attributes of element
    nnm := xmldom.getAttributes(n);
         n_child:=xmldom.getFirstChild(n);
    text_value:=xmldom.getNodeValue(n_child);
    dbms_output.put_line('val='||text_value);
    IF (xmldom.isNull(nnm) = FALSE) THEN
    len2 := xmldom.getLength(nnm);
              dbms_output.put_line('length='||len2);
    -- loop through attributes
    FOR i IN 0..len2-1 LOOP
    n := xmldom.item(nnm, i);
    attrname := xmldom.getNodeName(n);
    attrval := xmldom.getNodeValue(n);
    dbms_output.put(' ' || attrname || ' = ' || attrval);
    END LOOP;
    dbms_output.put_line('');
    END IF;
    END LOOP;
    END printElementAttributes;
    3. The package trying to insert into a PL/SQL table.
    CREATE OR REPLACE PACKAGE BODY XMLSTUD2 AS
    PROCEDURE STUDLOAD
    IS
    v_parser xmlparser.Parser;
    v_doc xmldom.DOMDocument;
    v_nl xmldom.DOMNodeList;
    v_n xmldom.DOMNode;
    DOC CLOB;
    v_out CLOB;
    n2 XMLDOM.DOMNODELIST;
    TYPE stuxml_type IS TABLE OF STUDENTS%ROWTYPE;
    s_tab stuxml_type := stuxml_type();
    --l_sturec students%rowtype;
    BEGIN
    -- Create a parser.
    v_parser := xmlparser.newParser;
    xmlparser.setValidationMode(v_parser, FALSE);
    DOC := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <com.welligent.Student.BasicStudent.Create>
    <ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" messagePriority="1" messageType="Sync">
    <Sender>
    <MessageId>
    <SenderAppId>com.openii.SyncRouter</SenderAppId>
    <ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
    <MessageSeq>53</MessageSeq>
    </MessageId>
    <Authentication>
    <AuthUserId>Router</AuthUserId>
    </Authentication>
    </Sender>
    <Datetime>
    <Year>2001</Year>
    <Month>3</Month>
    <Day>23</Day>
    <Hour>13</Hour>
    <Minute>47</Minute>
    <Second>30</Second>
    <SubSecond>223</SubSecond>
    <Timezone>6:00-GMT</Timezone>
    </Datetime>
    </ControlAreaSync>
    <DataArea>
    <NewData>
    <BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
    <StudentNumber>052589F201</StudentNumber>
    <ExternalIdNumber>1234567890</ExternalIdNumber>
    <StateIdNumber>123456</StateIdNumber>
    <Name>
    <LastName>Lopez</LastName>
    <FirstName>Maria</FirstName>
    <MiddleName>S</MiddleName>
    </Name>
    <Gender>Female</Gender>
    <BirthDate>
    <Month>1</Month>
    <Day>1</Day>
    <Year>1995</Year>
    </BirthDate>
    <Race>Hispanic</Race>
    <Ethnicity>Hispanic</Ethnicity>
    <PrimaryLanguage>English</PrimaryLanguage>
    <HouseholdLanguage>Spanish</HouseholdLanguage>
    <Address>
    <Street>123 Any Street</Street>
    <ApartmentNumber>12-D</ApartmentNumber>
    <City>Los Angeles</City>
    <County>Los Angeles</County>
    <State>CA</State>
    <ZipCode>90071</ZipCode>
    </Address>
    </BasicStudent>
    </NewData>
    </DataArea>
    </com.welligent.Student.BasicStudent.Create>';
    -- Parse the document and create a new DOM document.
    SYS.XMLPARSER.PARSECLOB ( v_parser, DOC );
    v_doc := SYS.XMLPARSER.getDocument(v_parser);
    -- Free resources associated with the Parser now it is no longer needed.
    xmlparser.freeParser(v_parser);
    -- Get a list of all the STUD nodes in the document using the XPATH syntax.
    v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address');
    dbms_output.put_line( 'New Stud processed on '||to_char(sysdate, 'YYYY-MON-DD'));
    -- Loop through the list and create a new record in a tble collection
    -- for each STUD record.
    FOR stud IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
    v_n := xmldom.item(v_nl, stud);
    s_tab.extend;
    -- Use XPATH syntax to assign values to he elements of the collection.
         --s_tab(s_tab.last).STUDENT_ID :=xslprocessor.valueOf(v_n,'StudentNumber');
         --s_tab(s_tab.last).SSN :=xslprocessor.valueOf(v_n,'ExternalIdNumber');
         --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'StateIdNumber');
         s_tab(s_tab.last).STUDENT_LAST_NAME :=xslprocessor.valueOf(v_n,'LastName');
         --dbms_output.put_line( s_tab(s_tab.last).STUDENT_LAST_NAME);
         s_tab(s_tab.last).STUDENT_FIRST_NAME :=xslprocessor.valueOf(v_n,'FirstName');
         --s_tab(s_tab.last).STUDENT_MI :=xslprocessor.valueOf(v_n,'MiddleName');
         --s_tab(s_tab.last).STUDENT_GENDER :=xslprocessor.valueOf(v_n,'Gender');
         --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Month');
         --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Day');
         --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Year');
         --s_tab(s_tab.last).STUDENT_RACE :=xslprocessor.valueOf(v_n,'Race');
         --s_tab(s_tab.last).STUDENT_ETHNIC :=xslprocessor.valueOf(v_n,'Ethnicity');
         --s_tab(s_tab.last).STUDENT_PRI_LANG :=xslprocessor.valueOf(v_n,'PrimaryLanguage');
         --s_tab(s_tab.last).STUDENT_SEC_LANG :=xslprocessor.valueOf(v_n,'HouseholdLanguage');
         --s_tab(s_tab.last).STUDENT_STREET :=xslprocessor.valueOf(v_n,'Street');
         --s_tab(s_tab.last).STUDENT_APART_NO :=xslprocessor.valueOf(v_n,'ApartmentNumber');
         --s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'City'); 
         --s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'County');
         --s_tab(s_tab.last).STUDENT_STATE :=xslprocessor.valueOf(v_n,'State');
         --s_tab(s_tab.last).STUDENT_ZIP :=xslprocessor.valueOf(v_n,'ZipCode');
    END LOOP;
    FOR stud IN s_tab.first..s_tab.last LOOP
    dbms_output.put_line( s_tab(s_tab.last).STUDENT_LAST_NAME);
    INSERT INTO STUDENTS (
    SHISID, SSN, DOE_SCHOOL_NUMBER,
    PATIENT_TYPE, TEACHER, HOMEROOM,
    STUDENT_LAST_NAME, STUDENT_FIRST_NAME, STUDENT_MI,
    STUDENT_DOB, STUDENT_BIRTH_CERT, STUDENT_COMM,
    STUDENT_MUSA, STUDENT_FAMSIZE, STUDENT_FAMINCOME,
    STUDENT_UNINSURED, STUDENT_LUNCH, STUDENT_ZIP,
    STUDENT_STATE, STUDENT_COUNTY, STUDENT_STREET,
    STUDENT_APART_NO, STUDENT_PHONE, STUDENT_H2O_TYPE,
    STUDENT_WASTE_TRT, STUDENT_HOME_SET, STUDENT_NONHOME_SET,
    STUDENT_GENDER, STUDENT_RACE, STUDENT_ETHNIC,
    STUDENT_PRI_LANG, STUDENT_SEC_LANG, STUDENT_ATRISK,
    EMER_COND_MEMO, ASSIST_DEVICE_TYPE, SCHOOL_ENTER_AGE,
    STUDENT_CURR_GRADE, S504_ELIG_DATE, S504_DEV_DATE,
    S504_REV_DATE, STUDENT_504, STUDENT_IEP,
    IEP_EXP_DATE, GRAD_CLASS, TYPE_DIPLOMA,
    GRADE_RETAIN, LIT_PASS_TEST_MATH, LIT_PASS_DATE_MATH,
    LIT_PASS_TEST_WRITE, LIT_PASS_DATE_WRITE, LIT_PASS_TEST_READ,
    LIT_PASS_DATE_READ, SPEC_ED_ELIG, SPEC_ED_CODE,
    TRANSPORT_CODE, TRANSPORT_NO, PRIME_HANDICAP,
    PRIME_HANDICAP_PERCENT, PRIME_HANDI_MANAGER, FIRST_ADD_HANDI,
    FIRST_ADD_HANDICAP_PERCENT, FIRST_ADD_HANDI_504, FIRST_ADD_HANDI_504_DATE,
    SECOND_ADD_HANDI, SECOND_ADD_HANDICAP_PERCENT, MED_EXTERNAL_NAME,
    INS_TYPE, INS_PRI, INS_NAME,
    INS_MEDICAID_NO, ELIGDATE, INS_PRIV_INSURANCE,
    INS_APPR_BILL, INS_APPR_DATE, INS_PARENT_APPR,
    INS_POL_NAME, INS_POL_NO, INS_CARRIER_NO,
    INS_CARRIER_NAME, INS_CARRIER_RELATE, INS_AFFECT_DATE,
    INS_COPAY_OV, INS_COPAY_RX, INS_COPAY_AMBUL,
    INS_COPAY_EMER, INS_COPAY_OUTPAT, STUDENT_INACTIVE,
    PHYS_ID, ENCOUNTERNUM, USERID,
    MODDATE, STUDENT_ID, S504_DISABILITY,
    CHAPTER1, WELLNESS_ENROLL, SCHOOL_OF_RESIDENCE,
    INITIAL_IEP_DATE, CALENDAR_TRACK, USA_BORN,
    ALT_ID, FUTURE_SCHOOL, IEP_LAST_MEETING,
    IEP_LAST_SETTING, IEP_LAST_REFER_EVAL, THIRD_ADD_HANDI,
    LEP, GIFTED, IEP_EXIT_REASON,
    CASE_MANAGER_ID, INTAKE_NOTES, CALLER_PHONE,
    CALL_DATE, CALLER_RELATIONSHIP, CALLER_NAME,
    BUSINESS_PHONE, FAX, EMAIL,
    HIGHEST_EDUCATION, INTAKE_DATE, SERVICE_COORDINATOR,
    DISCHARGE_DATE, DISCHARGE_REASON, DISCHARGE_NOTES,
    INTAKE_BY, INTAKE_STATUS, IEP_LAST_SERVED_DATE,
    IEP_APC_DATE, IEP_EXIT_DATE, ADDRESS2,
    LEGAL_STATUS, RELIGION, EMPLOYMENT_STATUS,
    TARG_POP_GROUP1, TARG_POP_GROUP2, MARITAL_STATUS,
    THIRD_ADD_HANDI_PERCENT, LAST_INTERFACE_DATE, SERVICE_PLAN_TYPE,
    CURRENT_JURISDICTION, FIPS, BIRTH_PLACE_JURISDICTION,
    BIRTH_PLACE_HOSPITAL, BIRTH_PLACE_STATE, BIRTH_PLACE_COUNTRY,
    OTHER_CLIENT_NAME, SIBLINGS_WITH_SERVICES, PERM_SHARE_INFORMATION,
    PERM_VERIFY_INSURANCE, REFERRING_AGENCY, REFERRING_INDIVIDUAL,
    AUTOMATIC_ELIGIBILITY, INTAKE_IEP_ID, FUTURE_SCHOOL2,
    FUTURE_SCHOOL3, TRANSLATOR_NEEDED, TOTAL_CHILDREN_IN_HOME,
    REFERRED_BY, FAMILY_ID, SCREENING_CONSENT_FLAG,
    PICTURE_FILE, DUAL_ENROLLED, DOE_SCHOOL_NUMBER2)
    VALUES (123456789012, null,null ,
    null,null,null ,s_tab(stud).STUDENT_LAST_NAME
    , s_tab(stud).STUDENT_LAST_NAME,null ,
    null ,null ,null ,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null, null,null );
    END LOOP;
    COMMIT;
    -- Free any resources associated with the document now it
    -- is no longer needed.
    xmldom.freeDocument(v_doc);
    END STUDLOAD;
    END XMLSTUD2;
    /

    Hi
    I have created a PLSQL package based Oracle Portal
    form. This is created a s a databse provider. I have
    following questions to check :
    1. How to capture return values from the package and
    display different messages on success or failure ?
    - http://download.oracle.com/docs/cd/B14099_19/portal.1014/b14135/pdg_portletbuilder.htm#BABBAFGI
    Step 16
    2. How to return to blank form by intializing already
    entered values after successfuly process of the form
    data.
    - http://download.oracle.com/docs/cd/B14099_19/portal.1014/b14135/pdg_portletbuilder.htm#BABGBCHH
    thanks
    Manjith

  • Loading datafrom a PL/SQL table into the Database table

    I have created two procedures to try and achieve the problem at hand.
    It retrieves and displays the record from a DBMS_OUTPUT.PUT_LINE prospective as indicated in (1&2), but I am having difficulty loading these values into a PL/SQL table from the package labeled as (3). I read your book and all but I do not see a solution to my problem
    All code compiles. (1&2) work together, (3) works by itself but will not populate the table, and I get no errors.
    1.The first being the one that retrieves the XML file and parses it.
    CREATE OR REPLACE procedure xml_main is
    P XMLPARSER.Parser;
    DOC CLOB;
    v_xmldoc xmldom.DOMDocument;
    v_out CLOB;
    BEGIN
    P := xmlparser.newParser;
    xmlparser.setValidationMode(p, FALSE);
    DOC := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <com.welligent.Student.BasicStudent.Create>
    <ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" messagePriority="1" messageType="Sync">
    <Sender>
    <MessageId>
    <SenderAppId>com.openii.SyncRouter</SenderAppId>
    <ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
    <MessageSeq>53</MessageSeq>
    </MessageId>
    <Authentication>
    <AuthUserId>Router</AuthUserId>
    </Authentication>
    </Sender>
    <Datetime>
    <Year>2001</Year>
    <Month>3</Month>
    <Day>23</Day>
    <Hour>13</Hour>
    <Minute>47</Minute>
    <Second>30</Second>
    <SubSecond>223</SubSecond>
    <Timezone>6:00-GMT</Timezone>
    </Datetime>
    </ControlAreaSync>
    <DataArea>
    <NewData>
    <BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
    <StudentNumber>052589F201</StudentNumber>
    <ExternalIdNumber>1234567890</ExternalIdNumber>
    <StateIdNumber>123456</StateIdNumber>
    <Name>
    <LastName>Lopez</LastName>
    <FirstName>Maria</FirstName>
    <MiddleName>S</MiddleName>
    </Name>
    <Gender>Female</Gender>
    <BirthDate>
    <Month>1</Month>
    <Day>1</Day>
    <Year>1995</Year>
    </BirthDate>
    <Race>Hispanic</Race>
    <Ethnicity>Hispanic</Ethnicity>
    <PrimaryLanguage>English</PrimaryLanguage>
    <HouseholdLanguage>Spanish</HouseholdLanguage>
    <Address>
    <Street>123 Any Street</Street>
    <ApartmentNumber>12-D</ApartmentNumber>
    <City>Los Angeles</City>
    <County>Los Angeles</County>
    <State>CA</State>
    <ZipCode>90071</ZipCode>
    </Address>
    </BasicStudent>
    </NewData>
    </DataArea>
    </com.welligent.Student.BasicStudent.Create>';
    --v_out := DOC;
    SYS.XMLPARSER.PARSECLOB ( P, DOC );
    v_xmldoc := SYS.XMLPARSER.getDocument(P);
    --DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION);
    --v_out := SYS.XMLPARSER.PARSECLOB ( P, DOC );
    --SYS.XMLDOM.writetoCLOB(v_xmldoc, v_out);
    --INSERT INTO TEST (TEST_COLUMN)
    --VALUES(V_OUT);
    --printElements(v_xmldoc);
    printElementAttributes(v_xmldoc);
    exception
    when xmldom.INDEX_SIZE_ERR then
    raise_application_error(-20120, 'Index Size error');
    when xmldom.DOMSTRING_SIZE_ERR then
    raise_application_error(-20120, 'String Size error');
    when xmldom.HIERARCHY_REQUEST_ERR then
    raise_application_error(-20120, 'Hierarchy request error');
    when xmldom.WRONG_DOCUMENT_ERR then
    raise_application_error(-20120, 'Wrong doc error');
    when xmldom.INVALID_CHARACTER_ERR then
    raise_application_error(-20120, 'Invalid Char error');
    when xmldom.NO_DATA_ALLOWED_ERR then
    raise_application_error(-20120, 'Nod data allowed error');
    when xmldom.NO_MODIFICATION_ALLOWED_ERR then
    raise_application_error(-20120, 'No mod allowed error');
    when xmldom.NOT_FOUND_ERR then
    raise_application_error(-20120, 'Not found error');
    when xmldom.NOT_SUPPORTED_ERR then
    raise_application_error(-20120, 'Not supported error');
    when xmldom.INUSE_ATTRIBUTE_ERR then
    raise_application_error(-20120, 'In use attr error');
    END;
    2. The second which displays the values from the .xml file I initialized above.
    CREATE OR REPLACE procedure printElementAttributes(doc xmldom.DOMDocument) is
    nl XMLDOM.DOMNODELIST;
    len1 NUMBER;
    len2 NUMBER;
    n XMLDOM.DOMNODE;
    e XMLDOM.DOMELEMENT;
    nnm XMLDOM.DOMNAMEDNODEMAP;
    attrname VARCHAR2(100);
    attrval VARCHAR2(100);
    text_value VARCHAR2(100):=NULL;
    n_child XMLDOM.DOMNODE;
    BEGIN
    -- get all elements
    nl := XMLDOM.getElementsByTagName(doc, '*');
    len1 := XMLDOM.getLength(nl);
    -- loop through elements
    FOR j in 0..len1-1 LOOP
    n := XMLDOM.item(nl, j);
    e := XMLDOM.makeElement(n);
    DBMS_OUTPUT.PUT_LINE(xmldom.getTagName(e) || ':');
    -- get all attributes of element
    nnm := xmldom.getAttributes(n);
    n_child:=xmldom.getFirstChild(n);
    text_value:=xmldom.getNodeValue(n_child);
    dbms_output.put_line('val='||text_value);
    IF (xmldom.isNull(nnm) = FALSE) THEN
    len2 := xmldom.getLength(nnm);
    dbms_output.put_line('length='||len2);
    -- loop through attributes
    FOR i IN 0..len2-1 LOOP
    n := xmldom.item(nnm, i);
    attrname := xmldom.getNodeName(n);
    attrval := xmldom.getNodeValue(n);
    dbms_output.put(' ' || attrname || ' = ' || attrval);
    END LOOP;
    dbms_output.put_line('');
    END IF;
    END LOOP;
    END printElementAttributes;
    3. The package trying to insert into a PL/SQL table.
    CREATE OR REPLACE PACKAGE BODY XMLSTUD2 AS
    PROCEDURE STUDLOAD
    IS
    v_parser xmlparser.Parser;
    v_doc xmldom.DOMDocument;
    v_nl xmldom.DOMNodeList;
    v_n xmldom.DOMNode;
    DOC CLOB;
    v_out CLOB;
    n2 XMLDOM.DOMNODELIST;
    TYPE stuxml_type IS TABLE OF STUDENTS%ROWTYPE;
    s_tab stuxml_type := stuxml_type();
    --l_sturec students%rowtype;
    BEGIN
    -- Create a parser.
    v_parser := xmlparser.newParser;
    xmlparser.setValidationMode(v_parser, FALSE);
    DOC := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <com.welligent.Student.BasicStudent.Create>
    <ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" messagePriority="1" messageType="Sync">
    <Sender>
    <MessageId>
    <SenderAppId>com.openii.SyncRouter</SenderAppId>
    <ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
    <MessageSeq>53</MessageSeq>
    </MessageId>
    <Authentication>
    <AuthUserId>Router</AuthUserId>
    </Authentication>
    </Sender>
    <Datetime>
    <Year>2001</Year>
    <Month>3</Month>
    <Day>23</Day>
    <Hour>13</Hour>
    <Minute>47</Minute>
    <Second>30</Second>
    <SubSecond>223</SubSecond>
    <Timezone>6:00-GMT</Timezone>
    </Datetime>
    </ControlAreaSync>
    <DataArea>
    <NewData>
    <BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
    <StudentNumber>052589F201</StudentNumber>
    <ExternalIdNumber>1234567890</ExternalIdNumber>
    <StateIdNumber>123456</StateIdNumber>
    <Name>
    <LastName>Lopez</LastName>
    <FirstName>Maria</FirstName>
    <MiddleName>S</MiddleName>
    </Name>
    <Gender>Female</Gender>
    <BirthDate>
    <Month>1</Month>
    <Day>1</Day>
    <Year>1995</Year>
    </BirthDate>
    <Race>Hispanic</Race>
    <Ethnicity>Hispanic</Ethnicity>
    <PrimaryLanguage>English</PrimaryLanguage>
    <HouseholdLanguage>Spanish</HouseholdLanguage>
    <Address>
    <Street>123 Any Street</Street>
    <ApartmentNumber>12-D</ApartmentNumber>
    <City>Los Angeles</City>
    <County>Los Angeles</County>
    <State>CA</State>
    <ZipCode>90071</ZipCode>
    </Address>
    </BasicStudent>
    </NewData>
    </DataArea>
    </com.welligent.Student.BasicStudent.Create>';
    -- Parse the document and create a new DOM document.
    SYS.XMLPARSER.PARSECLOB ( v_parser, DOC );
    v_doc := SYS.XMLPARSER.getDocument(v_parser);
    -- Free resources associated with the Parser now it is no longer needed.
    xmlparser.freeParser(v_parser);
    -- Get a list of all the STUD nodes in the document using the XPATH syntax.
    v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address');
    dbms_output.put_line( 'New Stud processed on '||to_char(sysdate, 'YYYY-MON-DD'));
    -- Loop through the list and create a new record in a tble collection
    -- for each STUD record.
    FOR stud IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
    v_n := xmldom.item(v_nl, stud);
    s_tab.extend;
    -- Use XPATH syntax to assign values to he elements of the collection.
    --s_tab(s_tab.last).STUDENT_ID :=xslprocessor.valueOf(v_n,'StudentNumber');
    --s_tab(s_tab.last).SSN :=xslprocessor.valueOf(v_n,'ExternalIdNumber');
    --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'StateIdNumber');
    s_tab(s_tab.last).STUDENT_LAST_NAME :=xslprocessor.valueOf(v_n,'LastName');
    --dbms_output.put_line( s_tab(s_tab.last).STUDENT_LAST_NAME);
    s_tab(s_tab.last).STUDENT_FIRST_NAME :=xslprocessor.valueOf(v_n,'FirstName');
    --s_tab(s_tab.last).STUDENT_MI :=xslprocessor.valueOf(v_n,'MiddleName');
    --s_tab(s_tab.last).STUDENT_GENDER :=xslprocessor.valueOf(v_n,'Gender');
    --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Month');
    --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Day');
    --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Year');
    --s_tab(s_tab.last).STUDENT_RACE :=xslprocessor.valueOf(v_n,'Race');
    --s_tab(s_tab.last).STUDENT_ETHNIC :=xslprocessor.valueOf(v_n,'Ethnicity');
    --s_tab(s_tab.last).STUDENT_PRI_LANG :=xslprocessor.valueOf(v_n,'PrimaryLanguage');
    --s_tab(s_tab.last).STUDENT_SEC_LANG :=xslprocessor.valueOf(v_n,'HouseholdLanguage');
    --s_tab(s_tab.last).STUDENT_STREET :=xslprocessor.valueOf(v_n,'Street');
    --s_tab(s_tab.last).STUDENT_APART_NO :=xslprocessor.valueOf(v_n,'ApartmentNumber');
    --s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'City');
    --s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'County');
    --s_tab(s_tab.last).STUDENT_STATE :=xslprocessor.valueOf(v_n,'State');
    --s_tab(s_tab.last).STUDENT_ZIP :=xslprocessor.valueOf(v_n,'ZipCode');
    END LOOP;
    FOR stud IN s_tab.first..s_tab.last LOOP
    dbms_output.put_line( s_tab(s_tab.last).STUDENT_LAST_NAME);
    INSERT INTO STUDENTS (
    SHISID, SSN, DOE_SCHOOL_NUMBER,
    PATIENT_TYPE, TEACHER, HOMEROOM,
    STUDENT_LAST_NAME, STUDENT_FIRST_NAME, STUDENT_MI,
    STUDENT_DOB, STUDENT_BIRTH_CERT, STUDENT_COMM,
    STUDENT_MUSA, STUDENT_FAMSIZE, STUDENT_FAMINCOME,
    STUDENT_UNINSURED, STUDENT_LUNCH, STUDENT_ZIP,
    STUDENT_STATE, STUDENT_COUNTY, STUDENT_STREET,
    STUDENT_APART_NO, STUDENT_PHONE, STUDENT_H2O_TYPE,
    STUDENT_WASTE_TRT, STUDENT_HOME_SET, STUDENT_NONHOME_SET,
    STUDENT_GENDER, STUDENT_RACE, STUDENT_ETHNIC,
    STUDENT_PRI_LANG, STUDENT_SEC_LANG, STUDENT_ATRISK,
    EMER_COND_MEMO, ASSIST_DEVICE_TYPE, SCHOOL_ENTER_AGE,
    STUDENT_CURR_GRADE, S504_ELIG_DATE, S504_DEV_DATE,
    S504_REV_DATE, STUDENT_504, STUDENT_IEP,
    IEP_EXP_DATE, GRAD_CLASS, TYPE_DIPLOMA,
    GRADE_RETAIN, LIT_PASS_TEST_MATH, LIT_PASS_DATE_MATH,
    LIT_PASS_TEST_WRITE, LIT_PASS_DATE_WRITE, LIT_PASS_TEST_READ,
    LIT_PASS_DATE_READ, SPEC_ED_ELIG, SPEC_ED_CODE,
    TRANSPORT_CODE, TRANSPORT_NO, PRIME_HANDICAP,
    PRIME_HANDICAP_PERCENT, PRIME_HANDI_MANAGER, FIRST_ADD_HANDI,
    FIRST_ADD_HANDICAP_PERCENT, FIRST_ADD_HANDI_504, FIRST_ADD_HANDI_504_DATE,
    SECOND_ADD_HANDI, SECOND_ADD_HANDICAP_PERCENT, MED_EXTERNAL_NAME,
    INS_TYPE, INS_PRI, INS_NAME,
    INS_MEDICAID_NO, ELIGDATE, INS_PRIV_INSURANCE,
    INS_APPR_BILL, INS_APPR_DATE, INS_PARENT_APPR,
    INS_POL_NAME, INS_POL_NO, INS_CARRIER_NO,
    INS_CARRIER_NAME, INS_CARRIER_RELATE, INS_AFFECT_DATE,
    INS_COPAY_OV, INS_COPAY_RX, INS_COPAY_AMBUL,
    INS_COPAY_EMER, INS_COPAY_OUTPAT, STUDENT_INACTIVE,
    PHYS_ID, ENCOUNTERNUM, USERID,
    MODDATE, STUDENT_ID, S504_DISABILITY,
    CHAPTER1, WELLNESS_ENROLL, SCHOOL_OF_RESIDENCE,
    INITIAL_IEP_DATE, CALENDAR_TRACK, USA_BORN,
    ALT_ID, FUTURE_SCHOOL, IEP_LAST_MEETING,
    IEP_LAST_SETTING, IEP_LAST_REFER_EVAL, THIRD_ADD_HANDI,
    LEP, GIFTED, IEP_EXIT_REASON,
    CASE_MANAGER_ID, INTAKE_NOTES, CALLER_PHONE,
    CALL_DATE, CALLER_RELATIONSHIP, CALLER_NAME,
    BUSINESS_PHONE, FAX, EMAIL,
    HIGHEST_EDUCATION, INTAKE_DATE, SERVICE_COORDINATOR,
    DISCHARGE_DATE, DISCHARGE_REASON, DISCHARGE_NOTES,
    INTAKE_BY, INTAKE_STATUS, IEP_LAST_SERVED_DATE,
    IEP_APC_DATE, IEP_EXIT_DATE, ADDRESS2,
    LEGAL_STATUS, RELIGION, EMPLOYMENT_STATUS,
    TARG_POP_GROUP1, TARG_POP_GROUP2, MARITAL_STATUS,
    THIRD_ADD_HANDI_PERCENT, LAST_INTERFACE_DATE, SERVICE_PLAN_TYPE,
    CURRENT_JURISDICTION, FIPS, BIRTH_PLACE_JURISDICTION,
    BIRTH_PLACE_HOSPITAL, BIRTH_PLACE_STATE, BIRTH_PLACE_COUNTRY,
    OTHER_CLIENT_NAME, SIBLINGS_WITH_SERVICES, PERM_SHARE_INFORMATION,
    PERM_VERIFY_INSURANCE, REFERRING_AGENCY, REFERRING_INDIVIDUAL,
    AUTOMATIC_ELIGIBILITY, INTAKE_IEP_ID, FUTURE_SCHOOL2,
    FUTURE_SCHOOL3, TRANSLATOR_NEEDED, TOTAL_CHILDREN_IN_HOME,
    REFERRED_BY, FAMILY_ID, SCREENING_CONSENT_FLAG,
    PICTURE_FILE, DUAL_ENROLLED, DOE_SCHOOL_NUMBER2)
    VALUES (123456789012, null,null ,
    null,null,null ,s_tab(stud).STUDENT_LAST_NAME
    , s_tab(stud).STUDENT_LAST_NAME,null ,
    null ,null ,null ,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null ,null , null,
    null, null,null );
    END LOOP;
    COMMIT;
    -- Free any resources associated with the document now it
    -- is no longer needed.
    xmldom.freeDocument(v_doc);
    END STUDLOAD;
    END XMLSTUD2;
    /

    Here's a first cut for you. Note that I've added some annotations to the XML Schema
    SQL>
    SQL>
    SQL> var schemaURL varchar2(256)
    SQL> var schemaPath varchar2(256)
    SQL> --
    SQL> begin
      2    :schemaURL := 'http://xmlns.welligent.com/xsd/Student.xsd';
      3    :schemaPath := '/public/Student.xsd';
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
      2  /
    Call completed.
    SQL> declare
      2    res boolean;
      3    xmlSchema xmlType := xmlType(
      4  '<xs:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      5     <xs:element name="Address" xdb:defaultTable="">
      6             <xs:complexType>
      7                     <xs:sequence>
      8                             <xs:element ref="Street"/>
      9                             <xs:element ref="ApartmentNumber"/>
    10                             <xs:element ref="City"/>
    11                             <xs:element ref="County"/>
    12                             <xs:element ref="State"/>
    13                             <xs:element ref="ZipCode"/>
    14                     </xs:sequence>
    15             </xs:complexType>
    16     </xs:element>
    17     <xs:element name="ApartmentNumber" xdb:defaultTable="">
    18             <xs:simpleType>
    19                     <xs:restriction base="xs:string">
    20                             <xs:enumeration value="12-D"/>
    21                     </xs:restriction>
    22             </xs:simpleType>
    23     </xs:element>
    24     <xs:element name="AuthUserId" xdb:defaultTable="">
    25             <xs:simpleType>
    26                     <xs:restriction base="xs:string">
    27                             <xs:enumeration value="Router"/>
    28                     </xs:restriction>
    29             </xs:simpleType>
    30     </xs:element>
    31     <xs:element name="Authentication" xdb:defaultTable="">
    32             <xs:complexType>
    33                     <xs:sequence>
    34                             <xs:element ref="AuthUserId"/>
    35                     </xs:sequence>
    36             </xs:complexType>
    37     </xs:element>
    38     <xs:element name="BasicStudent" xdb:defaultTable="">
    39             <xs:complexType>
    40                     <xs:sequence>
    41                             <xs:element ref="StudentNumber"/>
    42                             <xs:element ref="ExternalIdNumber"/>
    43                             <xs:element ref="StateIdNumber"/>
    44                             <xs:element ref="Name"/>
    45                             <xs:element ref="Gender"/>
    46                             <xs:element ref="BirthDate"/>
    47                             <xs:element ref="Race"/>
    48                             <xs:element ref="Ethnicity"/>
    49                             <xs:element ref="PrimaryLanguage"/>
    50                             <xs:element ref="HouseholdLanguage"/>
    51                             <xs:element ref="Address"/>
    52                     </xs:sequence>
    53                     <xs:attribute name="mealCode" type="xs:string" use="required"/>
    54                     <xs:attribute name="usBorn" use="required">
    55                             <xs:simpleType>
    56                                     <xs:restriction base="xs:string">
    57                                             <xs:enumeration value="Yes"/>
    58                                     </xs:restriction>
    59                             </xs:simpleType>
    60                     </xs:attribute>
    61                     <xs:attribute name="migrant" use="required">
    62                             <xs:simpleType>
    63                                     <xs:restriction base="xs:string">
    64                                             <xs:enumeration value="No"/>
    65                                     </xs:restriction>
    66                             </xs:simpleType>
    67                     </xs:attribute>
    68                     <xs:attribute name="workAbility" use="required">
    69                             <xs:simpleType>
    70                                     <xs:restriction base="xs:string">
    71                                             <xs:enumeration value="No"/>
    72                                     </xs:restriction>
    73                             </xs:simpleType>
    74                     </xs:attribute>
    75                     <xs:attribute name="ellStatus" type="xs:string" use="required"/>
    76             </xs:complexType>
    77     </xs:element>
    78     <xs:element name="BirthDate" xdb:defaultTable="">
    79             <xs:complexType>
    80                     <xs:sequence>
    81                             <xs:element ref="Month"/>
    82                             <xs:element ref="Day"/>
    83                             <xs:element ref="Year"/>
    84                     </xs:sequence>
    85             </xs:complexType>
    86     </xs:element>
    87     <xs:element name="City" xdb:defaultTable="">
    88             <xs:simpleType>
    89                     <xs:restriction base="xs:string">
    90                             <xs:enumeration value="Los Angeles"/>
    91                     </xs:restriction>
    92             </xs:simpleType>
    93     </xs:element>
    94     <xs:element name="ControlAreaSync" xdb:defaultTable="">
    95             <xs:complexType>
    96                     <xs:sequence>
    97                             <xs:element ref="Sender"/>
    98                             <xs:element ref="Datetime"/>
    99                     </xs:sequence>
    100                     <xs:attribute name="messageCategory" use="required">
    101                             <xs:simpleType>
    102                                     <xs:restriction base="xs:string">
    103                                             <xs:enumeration value="com.welligent.Student"/>
    104                                     </xs:restriction>
    105                             </xs:simpleType>
    106                     </xs:attribute>
    107                     <xs:attribute name="messageObject" use="required">
    108                             <xs:simpleType>
    109                                     <xs:restriction base="xs:string">
    110                                             <xs:enumeration value="BasicStudent"/>
    111                                     </xs:restriction>
    112                             </xs:simpleType>
    113                     </xs:attribute>
    114                     <xs:attribute name="messageAction" use="required">
    115                             <xs:simpleType>
    116                                     <xs:restriction base="xs:string">
    117                                             <xs:enumeration value="Create"/>
    118                                     </xs:restriction>
    119                             </xs:simpleType>
    120                     </xs:attribute>
    121                     <xs:attribute name="messageRelease" use="required">
    122                             <xs:simpleType>
    123                                     <xs:restriction base="xs:decimal">
    124                                             <xs:enumeration value="1.0"/>
    125                                     </xs:restriction>
    126                             </xs:simpleType>
    127                     </xs:attribute>
    128                     <xs:attribute name="messagePriority" use="required">
    129                             <xs:simpleType>
    130                                     <xs:restriction base="xs:byte">
    131                                             <xs:enumeration value="1"/>
    132                                     </xs:restriction>
    133                             </xs:simpleType>
    134                     </xs:attribute>
    135                     <xs:attribute name="messageType" use="required">
    136                             <xs:simpleType>
    137                                     <xs:restriction base="xs:string">
    138                                             <xs:enumeration value="Sync"/>
    139                                     </xs:restriction>
    140                             </xs:simpleType>
    141                     </xs:attribute>
    142             </xs:complexType>
    143     </xs:element>
    144     <xs:element name="County" xdb:defaultTable="">
    145             <xs:simpleType>
    146                     <xs:restriction base="xs:string">
    147                             <xs:enumeration value="Los Angeles"/>
    148                     </xs:restriction>
    149             </xs:simpleType>
    150     </xs:element>
    151     <xs:element name="DataArea" xdb:defaultTable="">
    152             <xs:complexType>
    153                     <xs:sequence>
    154                             <xs:element ref="NewData"/>
    155                     </xs:sequence>
    156             </xs:complexType>
    157     </xs:element>
    158     <xs:element name="Datetime">
    159             <xs:complexType>
    160                     <xs:sequence>
    161                             <xs:element ref="Year"/>
    162                             <xs:element ref="Month"/>
    163                             <xs:element ref="Day"/>
    164                             <xs:element ref="Hour"/>
    165                             <xs:element ref="Minute"/>
    166                             <xs:element ref="Second"/>
    167                             <xs:element ref="SubSecond"/>
    168                             <xs:element ref="Timezone"/>
    169                     </xs:sequence>
    170             </xs:complexType>
    171     </xs:element>
    172     <xs:element name="Day" xdb:defaultTable="">
    173             <xs:simpleType>
    174                     <xs:restriction base="xs:byte">
    175                             <xs:enumeration value="1"/>
    176                             <xs:enumeration value="23"/>
    177                     </xs:restriction>
    178             </xs:simpleType>
    179     </xs:element>
    180     <xs:element name="Ethnicity" xdb:defaultTable="">
    181             <xs:simpleType>
    182                     <xs:restriction base="xs:string">
    183                             <xs:enumeration value="Hispanic"/>
    184                     </xs:restriction>
    185             </xs:simpleType>
    186     </xs:element>
    187     <xs:element name="ExternalIdNumber" xdb:defaultTable="">
    188             <xs:simpleType>
    189                     <xs:restriction base="xs:int">
    190                             <xs:enumeration value="1234567890"/>
    191                     </xs:restriction>
    192             </xs:simpleType>
    193     </xs:element>
    194     <xs:element name="FirstName" xdb:defaultTable="">
    195             <xs:simpleType>
    196                     <xs:restriction base="xs:string">
    197                             <xs:enumeration value="Maria"/>
    198                     </xs:restriction>
    199             </xs:simpleType>
    200     </xs:element>
    201     <xs:element name="Gender" xdb:defaultTable="">
    202             <xs:simpleType>
    203                     <xs:restriction base="xs:string">
    204                             <xs:enumeration value="Female"/>
    205                     </xs:restriction>
    206             </xs:simpleType>
    207     </xs:element>
    208     <xs:element name="Hour" xdb:defaultTable="">
    209             <xs:simpleType>
    210                     <xs:restriction base="xs:byte">
    211                             <xs:enumeration value="13"/>
    212                     </xs:restriction>
    213             </xs:simpleType>
    214     </xs:element>
    215     <xs:element name="HouseholdLanguage" xdb:defaultTable="">
    216             <xs:simpleType>
    217                     <xs:restriction base="xs:string">
    218                             <xs:enumeration value="Spanish"/>
    219                     </xs:restriction>
    220             </xs:simpleType>
    221     </xs:element>
    222     <xs:element name="LastName" xdb:defaultTable="">
    223             <xs:simpleType>
    224                     <xs:restriction base="xs:string">
    225                             <xs:enumeration value="Lopez"/>
    226                     </xs:restriction>
    227             </xs:simpleType>
    228     </xs:element>
    229     <xs:element name="MessageId" xdb:defaultTable="">
    230             <xs:complexType>
    231                     <xs:sequence>
    232                             <xs:element ref="SenderAppId"/>
    233                             <xs:element ref="ProducerId"/>
    234                             <xs:element ref="MessageSeq"/>
    235                     </xs:sequence>
    236             </xs:complexType>
    237     </xs:element>
    238     <xs:element name="MessageSeq" xdb:defaultTable="">
    239             <xs:simpleType>
    240                     <xs:restriction base="xs:byte">
    241                             <xs:enumeration value="53"/>
    242                     </xs:restriction>
    243             </xs:simpleType>
    244     </xs:element>
    245     <xs:element name="MiddleName" xdb:defaultTable="">
    246             <xs:simpleType>
    247                     <xs:restriction base="xs:string">
    248                             <xs:enumeration value="S"/>
    249                     </xs:restriction>
    250             </xs:simpleType>
    251     </xs:element>
    252     <xs:element name="Minute" xdb:defaultTable="">
    253             <xs:simpleType>
    254                     <xs:restriction base="xs:byte">
    255                             <xs:enumeration value="47"/>
    256                     </xs:restriction>
    257             </xs:simpleType>
    258     </xs:element>
    259     <xs:element name="Month" xdb:defaultTable="">
    260             <xs:simpleType>
    261                     <xs:restriction base="xs:byte">
    262                             <xs:enumeration value="1"/>
    263                             <xs:enumeration value="3"/>
    264                     </xs:restriction>
    265             </xs:simpleType>
    266     </xs:element>
    267     <xs:element name="Name" xdb:defaultTable="">
    268             <xs:complexType>
    269                     <xs:sequence>
    270                             <xs:element ref="LastName"/>
    271                             <xs:element ref="FirstName"/>
    272                             <xs:element ref="MiddleName"/>
    273                     </xs:sequence>
    274             </xs:complexType>
    275     </xs:element>
    276     <xs:element name="NewData" xdb:defaultTable="">
    277             <xs:complexType>
    278                     <xs:sequence>
    279                             <xs:element ref="BasicStudent"/>
    280                     </xs:sequence>
    281             </xs:complexType>
    282     </xs:element>
    283     <xs:element name="PrimaryLanguage" xdb:defaultTable="">
    284             <xs:simpleType>
    285                     <xs:restriction base="xs:string">
    286                             <xs:enumeration value="English"/>
    287                     </xs:restriction>
    288             </xs:simpleType>
    289     </xs:element>
    290     <xs:element name="ProducerId" xdb:defaultTable="">
    291             <xs:simpleType>
    292                     <xs:restriction base="xs:string">
    293                             <xs:enumeration value="a72af712-90ea-43be-b958-077a87a29bfb"/>
    294                     </xs:restriction>
    295             </xs:simpleType>
    296     </xs:element>
    297     <xs:element name="Race" xdb:defaultTable="">
    298             <xs:simpleType>
    299                     <xs:restriction base="xs:string">
    300                             <xs:enumeration value="Hispanic"/>
    301                     </xs:restriction>
    302             </xs:simpleType>
    303     </xs:element>
    304     <xs:element name="Second" xdb:defaultTable="">
    305             <xs:simpleType>
    306                     <xs:restriction base="xs:byte">
    307                             <xs:enumeration value="30"/>
    308                     </xs:restriction>
    309             </xs:simpleType>
    310     </xs:element>
    311     <xs:element name="Sender" xdb:defaultTable="">
    312             <xs:complexType>
    313                     <xs:sequence>
    314                             <xs:element ref="MessageId"/>
    315                             <xs:element ref="Authentication"/>
    316                     </xs:sequence>
    317             </xs:complexType>
    318     </xs:element>
    319     <xs:element name="SenderAppId" xdb:defaultTable="">
    320             <xs:simpleType>
    321                     <xs:restriction base="xs:string">
    322                             <xs:enumeration value="com.openii.SyncRouter"/>
    323                     </xs:restriction>
    324             </xs:simpleType>
    325     </xs:element>
    326     <xs:element name="State" xdb:defaultTable="">
    327             <xs:simpleType>
    328                     <xs:restriction base="xs:string">
    329                             <xs:enumeration value="CA"/>
    330                     </xs:restriction>
    331             </xs:simpleType>
    332     </xs:element>
    333     <xs:element name="StateIdNumber" xdb:defaultTable="">
    334             <xs:simpleType>
    335                     <xs:restriction base="xs:int">
    336                             <xs:enumeration value="123456"/>
    337                     </xs:restriction>
    338             </xs:simpleType>
    339     </xs:element>
    340     <xs:element name="Street" xdb:defaultTable="">
    341             <xs:simpleType>
    342                     <xs:restriction base="xs:string">
    343                             <xs:enumeration value="123 Any Street"/>
    344                     </xs:restriction>
    345             </xs:simpleType>
    346     </xs:element>
    347     <xs:element name="StudentNumber" xdb:defaultTable="">
    348             <xs:simpleType>
    349                     <xs:restriction base="xs:hexBinary">
    350                             <xs:enumeration value="052589F201"/>
    351                     </xs:restriction>
    352             </xs:simpleType>
    353     </xs:element>
    354     <xs:element name="SubSecond" xdb:defaultTable="">
    355             <xs:simpleType>
    356                     <xs:restriction base="xs:short">
    357                             <xs:enumeration value="223"/>
    358                     </xs:restriction>
    359             </xs:simpleType>
    360     </xs:element>
    361     <xs:element name="Timezone" xdb:defaultTable="">
    362             <xs:simpleType>
    363                     <xs:restriction base="xs:string">
    364                             <xs:enumeration value="6:00-GMT"/>
    365                     </xs:restriction>
    366             </xs:simpleType>
    367     </xs:element>
    368     <xs:element name="Year" xdb:defaultTable="">
    369             <xs:simpleType>
    370                     <xs:restriction base="xs:short">
    371                             <xs:enumeration value="1995"/>
    372                             <xs:enumeration value="2001"/>
    373                     </xs:restriction>
    374             </xs:simpleType>
    375     </xs:element>
    376     <xs:element name="ZipCode" xdb:defaultTable="">
    377             <xs:simpleType>
    378                     <xs:restriction base="xs:int">
    379                             <xs:enumeration value="90071"/>
    380                     </xs:restriction>
    381             </xs:simpleType>
    382     </xs:element>
    383     <xs:element name="com.welligent.Student.BasicStudent.Create" xdb:defaultTable="STUDENT_TABLE">
    384             <xs:complexType>
    385                     <xs:sequence>
    386                             <xs:element ref="ControlAreaSync"/>
    387                             <xs:element ref="DataArea"/>
    388                     </xs:sequence>
    389             </xs:complexType>
    390     </xs:element>
    391  </xs:schema>');
    392  begin
    393    if (dbms_xdb.existsResource(:schemaPath)) then
    394      dbms_xdb.deleteResource(:schemaPath);
    395    end if;
    396    res := dbms_xdb.createResource(:schemaPath,xmlSchema);
    397  end;
    398  /
    PL/SQL procedure successfully completed.
    SQL> begin
      2    dbms_xmlschema.registerSchema
      3    (
      4      :schemaURL,
      5      xdbURIType(:schemaPath).getClob(),
      6      TRUE,TRUE,FALSE,TRUE
      7    );
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL> insert into STUDENT_TABLE values (xmltype(
      2  '<com.welligent.Student.BasicStudent.Create>
      3     <ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" me
    ssagePriority="1" messageType="Sync">
      4             <Sender>
      5                     <MessageId>
      6                             <SenderAppId>com.openii.SyncRouter</SenderAppId>
      7                             <ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
      8                             <MessageSeq>53</MessageSeq>
      9                     </MessageId>
    10                     <Authentication>
    11                             <AuthUserId>Router</AuthUserId>
    12                     </Authentication>
    13             </Sender>
    14             <Datetime>
    15                     <Year>2001</Year>
    16                     <Month>3</Month>
    17                     <Day>23</Day>
    18                     <Hour>13</Hour>
    19                     <Minute>47</Minute>
    20                     <Second>30</Second>
    21                     <SubSecond>223</SubSecond>
    22                     <Timezone>6:00-GMT</Timezone>
    23             </Datetime>
    24     </ControlAreaSync>
    25     <DataArea>
    26             <NewData>
    27                     <BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
    28                             <StudentNumber>052589F201</StudentNumber>
    29                             <ExternalIdNumber>1234567890</ExternalIdNumber>
    30                             <StateIdNumber>123456</StateIdNumber>
    31                             <Name>
    32                                     <LastName>Lopez</LastName>
    33                                     <FirstName>Maria</FirstName>
    34                                     <MiddleName>S</MiddleName>
    35                             </Name>
    36                             <Gender>Female</Gender>
    37                             <BirthDate>
    38                                     <Month>1</Month>
    39                                     <Day>1</Day>
    40                                     <Year>1995</Year>
    41                             </BirthDate>
    42                             <Race>Hispanic</Race>
    43                             <Ethnicity>Hispanic</Ethnicity>
    44                             <PrimaryLanguage>English</PrimaryLanguage>
    45                             <HouseholdLanguage>Spanish</HouseholdLanguage>
    46                             <Address>
    47                                     <Street>123 Any Street</Street>
    48                                     <ApartmentNumber>12-D</ApartmentNumber>
    49                                     <City>Los Angeles</City>
    50                                     <County>Los Angeles</County>
    51                                     <State>CA</State>
    52                                     <ZipCode>90071</ZipCode>
    53                             </Address>
    54                     </BasicStudent>
    55             </NewData>
    56     </DataArea>
    57  </com.welligent.Student.BasicStudent.Create>'))
    58  /
    1 row created.
    SQL>
    SQL>
    SQL>

  • Problem with clob_write under client 9.2.0.6: UnsatisfiedLinkError

    Hi all,
    I'm running Oracle client 9.2.0.4 on Windows XP and Java 1.4.1_3.
    Writing or reading clob's works pretty well.
    As i tried to update to Oracle client 9.2.0.6, i got the error
    Communication failed: java.lang.UnsatisfiedLinkError: clob_write when i tried to write a clob. The same error appears when i tried to read a clob.
    Is there a specific problem with clobs under this client?
    All other JDBC operations work as good as before.
    Thanks.

    Here is another hint.
    In your classpath, use the jdbc driver that's under your oracle installation to which you are trying to connect to (ie, <ORACLE_HOME>\ora92\jdbc\lib\ojdbc14.jar).
    I had the same problem in 9.2.0.6 and its gone when I replaced the ojdbc14.jar. I copied the ..\ora92\jdbc\lib\ojdbc14.jar to my java client program's classpath, and ran the java client without getting the UnsatisfiedLinkError.
    It looks like the ocijdbc9.dll under ora92\bin has to match correctly with the jdbc drivers you would be using. I got this idea from this link:
    http://episteme.arstechnica.com/groupee/forums/a/tpc/f/6330927813/m/705001068631/inc/-1
    Hope this helps.

  • Read Fixed length file

    I have a text file that has data in specific positions of the file.
    ie.
    Pos 1-20 Name
    Pos 21-30 Division
    Pos 31-38 Birthdate
    I saved the file in the DB and want to process it to read the data in the specific positions I listed above.
    I started with the code below, but not sure how to get to the specific positions in the file.
    DECLARE
    v_blob_data BLOB;
    v_blob_len NUMBER;
    v_clob_data CLOB := 'anything';
    v_clob_len NUMBER;
    dest_offset NUMBER := 1;
    src_offset NUMBER := 1;
    blob_csid NUMBER := dbms_lob.default_csid;
    lang_ctx INTEGER := dbms_lob.default_lang_ctx;
    warning INTEGER;
    BEGIN
    select blob_content into v_blob_data from wwv_flow_files;
    v_blob_len := dbms_lob.getlength(v_blob_data);
    dbms_lob.converttoclob(v_clob_data, v_blob_data, v_blob_len,dest_offset,src_offset,blob_csid,lang_ctx,warning);
    END;

    bobmagan wrote:
    Unfortunately, I have to do this inside of an APEX page using pl/sql.What is unfortunate about that!? Apex is good. PL/SQL is awesome.{noformat} :-) {noformat}
    I would not have it any other way. Seriously.
    If the file is uploaded into Apex - then you still can use external tables.
    The basic steps are:
    1. spool the uploaded file (from the Apex flow files table) to the local file system of the Oracle server using UTL_FILE
    2. alter the external table and specify the newly created file's location
    3. select from the external data to load the file contents
    Alternatively, you need to write your own CLOB parser - that can read lines from the CLOB, parse these, and output the tokens to use (e.g. token 1 is the invoice id, token 2 the invoice date, etc).
    This all is very much doable in PL/SQL. And Apex is PL/SQL - and allows you to call your own PL/SQL packages and code to process data.
    Keep in mind that the simpler a process is, the easier it is to write, maintain and debug. Doing manual parsing.. not something that should be treated lightly as that can become quite complex.
    Dealing with an external table and its easy definition of the format of the file content to load, is a lot easier and more flexible. The only downside is having to spool the CLOB to an external file in order to use the external table... However... I do recall a few months ago looking at the "cartridge" used by Oracle to load external files as an external table, and read/saw something that seemed to also support CLOBs..?
    So I'm not sure if one can now define an external table and use it to load CLOB contents - worth looking at... and even if not, also worth considering spooling a CLOB to external file for loading via the external table interface.
    Unless of course you're keen to put your regex kung fu skills to use in writing a custom CLOB parser for the file contents.

  • XMLParser error in PL/SQL

    I am using DBMS_XMLParser in Oracle 10g to parse an XML. The code is as follows:
    CREATE OR REPLACE procedure xml_main is
    P DBMS_XMLPARSER.Parser;
    DOC CLOB;
    v_xmldoc DBMS_XMLDOM.DOMDocument;
    v_out CLOB;
    BEGIN
    P := DBMS_XMLPARSER.newParser;
    DBMS_XMLPARSER.setValidationMode(p, FALSE);
    DOC := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <com.welligent.Student.BasicStudent.Create>
    <ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" messagePriority="1" messageType="Sync">
    <Sender>
    <MessageId>
    <SenderAppId>com.openii.SyncRouter</SenderAppId>
    <ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
    <MessageSeq>53</MessageSeq>
    </MessageId>
    <Authentication>
    <AuthUserId>Router</AuthUserId>
    </Authentication>
    </Sender>
    <Datetime>
    <Year>2001</Year>
    <Month>3</Month>
    <Day>23</Day>
    <Hour>13</Hour>
    <Minute>47</Minute>
    <Second>30</Second>
    <SubSecond>223</SubSecond>
    <Timezone>6:00-GMT</Timezone>
    </Datetime>
    </ControlAreaSync>
    <DataArea>
    <NewData>
    <BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
    <StudentNumber>052589F201</StudentNumber>
    <ExternalIdNumber>1234567890</ExternalIdNumber>
    <StateIdNumber>123456</StateIdNumber>
    <Name>
    <LastName>Lopez</LastName>
    <FirstName>Maria</FirstName>
    <MiddleName>S</MiddleName>
    </Name>
    <Gender>Female</Gender>
    <BirthDate>
    <Month>1</Month>
    <Day>1</Day>
    <Year>1995</Year>
    </BirthDate>
    <Race>Hispanic</Race>
    <Ethnicity>Hispanic</Ethnicity>
    <PrimaryLanguage>English</PrimaryLanguage>
    <HouseholdLanguage>Spanish</HouseholdLanguage>
    <Address>
    <Street>123 Any Street</Street>
    <ApartmentNumber>12-D</ApartmentNumber>
    <City>Los Angeles</City>
    <County>Los Angeles</County>
    <State>CA</State>
    <ZipCode>90071</ZipCode>
    </Address>
    </BasicStudent>
    </NewData>
    </DataArea>
    </com.welligent.Student.BasicStudent.Create>';
    DBMS_XMLPARSER.PARSECLOB ( P, DOC );
    v_xmldoc := DBMS_XMLPARSER.getDocument(P);
    printElementAttributes(v_xmldoc);
    exception
    when DBMS_XMLDOM.INDEX_SIZE_ERR then
    raise_application_error(-20120, 'Index Size error');
    when DBMS_XMLDOM.DOMSTRING_SIZE_ERR then
    raise_application_error(-20120, 'String Size error');
    when DBMS_XMLDOM.HIERARCHY_REQUEST_ERR then
    raise_application_error(-20120, 'Hierarchy request error');
    when DBMS_XMLDOM.WRONG_DOCUMENT_ERR then
    raise_application_error(-20120, 'Wrong doc error');
    when DBMS_XMLDOM.INVALID_CHARACTER_ERR then
    raise_application_error(-20120, 'Invalid Char error');
    when DBMS_XMLDOM.NO_DATA_ALLOWED_ERR then
    raise_application_error(-20120, 'Nod data allowed error');
    when DBMS_XMLDOM.NO_MODIFICATION_ALLOWED_ERR then
    raise_application_error(-20120, 'No mod allowed error');
    when DBMS_XMLDOM.NOT_FOUND_ERR then
    raise_application_error(-20120, 'Not found error');
    when DBMS_XMLDOM.NOT_SUPPORTED_ERR then
    raise_application_error(-20120, 'Not supported error');
    when DBMS_XMLDOM.INUSE_ATTRIBUTE_ERR then
    raise_application_error(-20120, 'In use attr error');
    END;
    CREATE OR REPLACE procedure printElementAttributes(doc DBMS_XMLDOM.DOMDocument) is
    nl DBMS_XMLDOM.DOMNODELIST;
    len1 NUMBER;
    len2 NUMBER;
    n DBMS_XMLDOM.DOMNODE;
    e DBMS_XMLDOM.DOMELEMENT;
    nnm DBMS_XMLDOM.DOMNAMEDNODEMAP;
    attrname VARCHAR2(100);
    attrval VARCHAR2(100);
    text_value VARCHAR2(100):=NULL;
    n_child DBMS_XMLDOM.DOMNODE;
    BEGIN
    -- get all elements
    nl := DBMS_XMLDOM.getElementsByTagName(doc, '*');
    len1 := DBMS_XMLDOM.getLength(nl);
    -- loop through elements
    FOR j in 0..len1-1 LOOP
    n := DBMS_XMLDOM.item(nl, j);
    e := DBMS_XMLDOM.makeElement(n);
    DBMS_OUTPUT.PUT_LINE(DBMS_XMLDOM.getTagName(e) || ':');
    -- get all attributes of element
    nnm := DBMS_XMLDOM.getAttributes(n);
    n_child:=DBMS_XMLDOM.getFirstChild(n);
    text_value:=DBMS_XMLDOM.getNodeValue(n_child);
    dbms_output.put_line('val='||text_value);
    IF (DBMS_XMLDOM.isNull(nnm) = FALSE) THEN
    len2 := DBMS_XMLDOM.getLength(nnm);
    dbms_output.put_line('length='||len2);
    -- loop through attributes
    FOR i IN 0..len2-1 LOOP
    n := DBMS_XMLDOM.item(nnm, i);
    attrname := DBMS_XMLDOM.getNodeName(n);
    attrval := DBMS_XMLDOM.getNodeValue(n);
    dbms_output.put(' ' || attrname || ' = ' || attrval);
    END LOOP;
    dbms_output.put_line('');
    END IF;
    END LOOP;
    END printElementAttributes;
    While executing the xml_main proc from an anonymous block, I am getting the following error:
    ORA-04063: package body "XDB.DBMS_XMLPARSER" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "XDB.DBMS_XMLPARSER"
    ORA-06512: at "BALB.XML_MAIN", line 9
    ORA-06512: at line 2
    I've checked that the XDB is installed in my database by running the below query and getting the output
    select comp_name, version, status
    from dba_registry
    where comp_name like '%XML%';
    COMP_NAME VERSION STATUS
    Oracle XML Database 10.2.0.2.0 VALID
    1 row selected.
    Please let me know a way out to resolve it?

    It worked for me. I ran your code fine in Oracle 10g. Now 9i is probably a different story.

  • Oracle 9i +Java: Change string encoding from UTF-16 to Windows-1251

    Dear colleagues,
    I have a very urgent case: need to change encoding of the string retrieved from the file (with encoding UTF-16) to Windows-1251 and put it to db table, to CLOB field.
    Code of the Java function
    +public static void file2table(String sql, String fileName, String characterSet, int asByteArray) throws SQLException, IOException {+
    Connection con = null;
    Writer writer = null;
    Reader reader = null;
    +try {+
    con = getConnection();
    PreparedStatement ps=con.prepareStatement(sql);
    reader = new InputStreamReader(new BufferedInputStream(new FileInputStream(new File(fileName))), characterSet);
    BufferedReader br = new BufferedReader(reader);
    String s;
    +while ((s = br.readLine()) != null) {+
    byte[] defaultBytes=s.getBytes(characterSet);
    String win1251str=new String(defaultBytes, "windows-1251");
    +if(asByteArray>0) {+
    ps.setBytes(1, defaultBytes);
    +//ps.setBytes(1, win1251str.getBytes("windows-1251"));+
    +} else {+
    ps.setString(1, s);
    +}+
    ps.executeUpdate();
    +}+
    con.commit();
    +} finally {+
    +if (reader != null) {reader.close();}+
    +if (con != null) {con.close();}+
    +}+
    +}+
    I was check, all bytes from the file received correctly. But if I put readed bytes to database table, result text in table is broken.

    >
    Yes, currently I already have filled table with all file lines in result table but with incorrect encoding
    >
    No you haven't - not using the code you posted. You can't save LOB data using only the BLOB or CLOB.
    That isn't data that you strored - it is garbage that is being stored as the LOB locator.
    I ask you why you were trying to store the data that way instead of the way the doc shows you and you said
    >
    Because var. s is type of Java String.
    For method setClob must be use type of CLOB
    >
    You are teriibly confused about LOBs. A BLOB or CLOB Java datatype is the LOB LOCATOR and doesn't contain any data.
    Yes - it is true that method setClob must be of type CLOB but that CLOB instance HAS TO BE THE LOB LOCATOR - not the data.
    You access LOB data using streams. To store LOB data you have to RETRIEVE (not send) a LOB locator from the database and then use the locator's stream to send the actual data.
    So if you are creating a new record in the table you typically do an INSERT that includes an EMPTY_LOB() and have the newly created LOB locator returned to you. Then you use that locators stream to send the actual data.
    Since you are not doing that your approach will not work.
    Here is a link to the 9i JDBC Dev Guide
    http://docs.oracle.com/cd/B10501_01/java.920/a96654.pdf
    See page 8-2 to start with
    >
    BLOB and CLOB data is
    accessed and referenced by using a locator, which is stored in the database table and
    points to the BLOB or CLOB data, which is outside the table.
    To work with LOB data, you must first obtain a LOB locator. Then you can read or
    write LOB data and perform data manipulation. The following sections also
    describe how to create and populate a LOB column in a table.
    The oracle.sql.BLOB and CLOB classes implement the java.sql.Blob and
    Clob interfaces, respectively (oracle.jdbc2.Blob and Clob interfaces under
    JDK 1.1.x). By contrast, BFILE is an Oracle extension, without a corresponding
    java.sql (or oracle.jdbc2) interface.
    Instances of these classes contain only the locators for these datatypes, not the data.
    After accessing the locators, you must perform some additional steps to access the
    data. These steps are described in "Reading and Writing BLOB and CLOB Data" on
    page 8-6 and "Reading BFILE Data" on page 8-22.
    Note: You cannot construct BLOB, CLOB, or BFILE objects in your
    JDBC application—you can only retrieve existing BLOBs, CLOBs,
    or BFILEs from the database or create them using the
    createTemporary() and empty_lob() methods.
    >
    Read the above quotes several times until you understand what they are telling you. These are the two main concepts you need to accept:
    >
    To work with LOB data, you must first obtain a LOB locator.
    You cannot construct BLOB, CLOB, or BFILE objects in your JDBC application
    >
    See the example code and description starting on page 8-11 for how to populate a LOB column in a table
    >
    Create a BLOB or CLOB column in a table with the SQL CREATE TABLE statement,
    then populate the LOB. This includes creating the LOB entry in the table, obtaining
    the LOB locator, creating a file handler for the data (if you are reading the data from
    a file), and then copying the data into the LOB.
    >
    Until you start using the proper methodology you are just wasting you time and will not be successful.

Maybe you are looking for