DBMS_XMLQuery and DBMS_XMLSave

Hi, could somebody help me!
I have Oracle 8.1.7. Where can I get code samples of using these packages?
Especially DBMS_XMLSave!
Thanks in advice.

Another one:
DBMS_XMLSAVE has support for setDateFormat, but DBMS_XMLSTORE does not. You are at the mercy of the NLS parameters.
I wish that all the XML procedures would conform to XML datetime formats, so you you know when retreiving a date from Oracle you will always get yyyy-mm-ddTHH:mi:ss and when writing back you simply need to supply this same format.

Similar Messages

  • DBMS_XMLQuery and DBMS_XMLSave package

    I have Oracle 8.1.7
    Where can I get DBMS_XMLQuery and DBMS_XMLSave package using samples
    The Documentation I have doesn't contain any.

    I did what you asked, but still get the following error when running my statement to create xml from a sql statement.
    SQL> @xml01
    declare
    ERROR at line 1:
    ORA-29541: class SYS.oracle/xml/sql/query/OracleXMLStaticQuery could not be
    resolved
    ORA-06512: at "SYS.DBMS_XMLQUERY", line 46
    ORA-06512: at line 7
    Below is copy of the contents of catxsu.sql script.
    call sys.dbms_java.loadjava ('-v -r -s -grant PUBLIC rdbms/jlib/xsu12.jar');
    @@dbmsxsu.sql
    @@xmlgen.sql
    create public synonym dbms_xmlsave for dbms_xmlsave;
    create public synonym dbms_xmlquery for dbms_xmlquery;
    create public synonym xmlgen for xmlgen;
    Below is output from catxsu.sql run this time.
    SQL> @catxsu
    Call completed.
    Package created.
    No errors.
    Package body created.
    No errors.
    Grant succeeded.
    Package created.
    No errors.
    Package body created.
    No errors.
    Grant succeeded.
    Package created.
    No errors.
    Package body created.
    No errors.
    Grant succeeded.
    create public synonym dbms_xmlsave for dbms_xmlsave
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    create public synonym dbms_xmlquery for dbms_xmlquery
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    create public synonym xmlgen for xmlgen
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    SQL> exit
    I appreciate your help. Any more ideas? This is working for me on another server and database, but not sure what the difference is with this one.
    Thanks,
    Tim Gerringer

  • QUOTED IDENTIFIER (DASH in COLUMN NAME) - and DBMS_XMLSAVE

    I HAD to create a View where the column names had embedded dashes in order to correspond to the XML I am receiving. The view contains the columns:
    V_VEND_H_XML - view name
    BATCH-UNIQUE-ID
    ADD-COUNT
    MODIFY-COUNT
    DELETE-COUNT
    REACTIVATE-COUNT
    TRANSACTION-DATE
    ACTION-TIME
    When I created it and when I reference a column I am supposed to put the column name in double quotes (").
    I am encountering 2 problems when I try to use these column.
    1. I need to do the following functions/procedures and provide the column name:
    DBMS_XMLSave.setKeyColumn(l_ctx,'"BATCH-UNIQUE-ID"');
    DBMS_XMLSave.setUpdateColumn(l_ctx,'"ADD-COUNT"');
    DBMS_XMLSave.setUpdateColumn(l_ctx,'"MODIFY-COUNT"');
    DBMS_XMLSave.setUpdateColumn(l_ctx,'"DELETE-COUNT"');
    DBMS_XMLSave.setUpdateColumn(l_ctx,'"REACTIVATE-COUNT"');
    DBMS_XMLSave.setUpdateColumn(l_ctx,'"TRANSACTION-DATE"');
    DBMS_XMLSave.setUpdateColumn(l_ctx,'"ACTION-TIME"');
    DBMS_XMLSave.setCommitBatch(l_ctx, 0);
    V_rowcount := DBMS_XMLSave.updateXML(l_ctx, v_clob);
    (I have tried with and without the double quotes - inside the require single quotes)
    In the example above, I get an error which implies that the package code is changing the case to lower case (see "batch-unique-id" below)
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.sql.OracleXMLSQLException: Column '"batch-unique-id"', specified to be a key column, does not not exits in table 'V_IFMIS_VEND_XML_H_XMIT2'.
    ORA-06512: at "SYS.DBMS_XMLSAVE", line 65
    ORA-06512: at line 48
    Does anyone know how I can make this work?

    This is a genuine bug, not specific to XE. Here is a minimal testcase:
    -- Use a fresh-from-the-seed database
    CONNECT Sys/Sys@11202 AS SYSDBA
    create edition e1 as child of Ora$Base
    alter session set edition = e1
    alter database default edition = e1
    -- Wait for MMON to switch over
    begin DBMS_Lock.Sleep(5); end;
    drop edition Ora$Base cascade
    SHUTDOWN IMMEDIATE
    STARTUP
    -- Causes ORA-00600
    begin DBMS_Output.Put_Line('Hello'); end;
    I filed bug 12758386.
    Notice that all other reported problems were user errors. I've explained those in an offline email exchange with Alex.

  • Error while using dbms_xmlsave.UpdateXML and dbms_xmlsave.insertXML

    The Record I am trying to insert/update has the following structure
    <ROWSET>
    <ROW>
    <COL1>123</COL1>
    </ROW>
    </ROWSET>
    Table structure is as below
    COL1 INT [Primary constraint]
    COL2 VARCHAR2(100) NOT NULL [but has default value of 'COL2_Default']
    Now since the XML doesn't have the entry for COL2, I am explicitly setting the columns to be updated/inserted using dbms_xmlsave.setUpdateColumn.
    I use the logic the following logic to insert/update the table
    -- set the primary key column name. This forms the where clause for update statement
    dbms_xmlsave.setkeycolumn(l_Context , 'COL1');
    -- cXML have the XML structure mentioned above
    l_rows := dbms_xmlsave.updateXML(l_Context, cXML);
    IF l_rows <= 0 THEN -- which means no rows found for update
    l_rows := dbms_xmlsave.insertXML(l_Context, cXML);
    END IF;
    Now when the excution of dbms_xmlsave.updateXML happens Java Runtime Error is thrown.
    ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.sql.OracleXMLSQLException: 'java.sql.SQLException: Missing IN or OUT parameter at index:: 5' encountered during processing ROW element 0. All prior XML row changes were rolled back. in the XML document.
    The version of oracle I am using is 9.2.0.6.0.
    Please let me know if anyone has any idea on this error.

    Found maybe an applicable reference...
    On http://publib.boulder.ibm.com/infocenter/wasinfo/v4r0/index.jsp?topic=/com.ibm.support.was.doc/html/Java_2_Connectivity_(J2C)/1163246.html
    it says:
    * Application code is missing a setXXX method call somewhere.
    * There might be a problem in the Oracle JDBC driver code.
    If the latter is the problem than you should or try a different JDBC driver or (which is probably the best solution anyway) create an iTar with Oracle support via metalink.oracle.com
    Other references can also be found on the internet when using google which could be applicable. Search on keywords: "Missing IN or OUT parameter at index"
    Message was edited by:
    mgralike

  • Backup/Recovery from web application

    Hello guys,
    I am using Oracle 9i as DB and Oracle 9iAS for web application server. I want to provide Backup and Recovery functionality to the user via web. I don't know any thing in this regard.
    Is it possible that we can take backup and recovery from web application?
    Is there any alternative for this function.
    any other comments will be appreciated.
    Thank you,
    Jawed Nazar Ali

    Read this article in order to get an idea about Java Stored Procedures.
    Oracle Developer JAVA STORED PROCEDURES
    Simplify with Java Stored Procedures
    By Kuassi Mensah
    Use Java stored procedures to bridge SQL, XML, Java, and J2EE and Web Services.
    Stored procedures allow a clean separation of persistence logic that runs in the database tier from business logic that runs in the middle tier. This separation reduces overall application complexity and increases reuse, security, performance, and scalability.
    A major obstacle, however, for widespread adoption of stored procedures is the set of various proprietary, database-dependent implementation languages that different database vendors use. The use of Java-based stored procedures fixes this concern. Oracle has implemented ANSI standards that specify the ability to invoke static Java methods from SQL as procedures or functions. This implementation is called simply "Java stored procedures."
    In this article, you will learn how Java stored procedures help simplify and increase the performance of your business logic and extend database functionality. I'll show how Oracle enables the use of Java stored procedures within the database. I'll also look at how Java stored procedures access data, and show how to create a basic Java stored procedure.
    PL/SQL or Java
    When you think of Oracle stored procedures, you probably think of PL/SQL. Oracle, however, has provided Java support in the database since Oracle8i, to offer an open and portable alternative to PL/SQL for stored procedures. I can hear the $64,000 question: "How do I choose between PL/SQL and Java? Should I forget all the things I've been told about PL/SQL and move on to the greener Java pastures?"
    Both languages are suitable for database programming, and each has its strengths and weaknesses. In deciding which language to use, here's a general rule of thumb:
    Use PL/SQL for database-centric logic that requires seamless integration with SQL and therefore complete access to database objects, types, and features.
    Use Java as an open alternative to PL/SQL for database independence, but also for integrating and bridging the worlds of SQL, XML, J2EE, and Web services.
    OracleJVM Lets You Run Java within the Database
    Since Oracle8i, Release 1 (Oracle 8.1.5), Oracle has offered a tightly integrated Java virtual machine (JVM) that supports Oracle's database session architecture. Any database session may activate a virtually dedicated JVM during the first Java code invocation; subsequent users then benefit from this already Java-enabled session. In reality, all sessions share the same JVM code and statics—only private states are kept and garbage collected in an individual session space, to provide Java sessions the same session isolation and data integrity capabilities as SQL operations. There is no need for a separate Java-enabled process for data integrity. This session-based architecture provides a small memory footprint and gives OracleJVM the same linear SMP scalability as the Oracle database.
    Creating Java Stored Procedures
    There are a few steps involved in turning a Java method into a Java stored procedure. These include loading the Java class into the database using the loadjava utility, and publishing the Java methods using a call specification (Call Spec) to map Java methods, parameter types, and return types to their SQL counterparts. The following section shows how to do this.
    I'll use a simple Hello class, with one method, Hello.world(), that returns the string "Hello world":
    public class Hello
    public static String world ()
    return "Hello world";
    The Loadjava Utility
    Loadjava is a utility for loading Java source files, Java class files, and Java resource files; verifying bytecodes; and deploying Java classes and JAR files into the database. It is invoked either from the command line or through the loadjava() method contained within the DBMS_JAVA class. To load our Hello.class example, type:
    loadjava -user scott/tiger Hello.class
    As of Oracle9i Release 2, loadjava allows you to automatically publish Java classes as stored procedures by creating the corresponding Call Specs for methods contained in the processed classes. Oracle provides Oracle9i JDeveloper for developing, testing, debugging, and deploying Java stored procedures.
    The Resolver Spec
    The JDK-based JVM looks for and resolves class references within the directories listed in the CLASSPATH. Because Oracle database classes live in the database schema, the OracleJVM uses a database resolver to look for and resolve class references through the schemas listed in the Resolver Spec. Unlike the CLASSPATH, which applies to all classes, the Resolver Spec is applied on a per-class basis. The default resolver looks for classes first in the schema in which the class is loaded and then for classes with public synonyms.
    loadjava -resolve <myclass>
    You may need to specify different resolvers, and you can force resolution to occur when you use loadjava, to determine at deployment time any problems that may occur later at runtime.
    loadjava -resolve -resolver "((* SCOTT) (foo/bar/* OTHERS)
    (* PUBLIC))"
    Call Spec and Stored Procedures Invocation
    To invoke a Java method from SQL (as well as from PL/SQL and JDBC), you must first publish the public static method through a Call Spec, which defines for SQL the arguments the method takes and the SQL types it returns.
    In our example, we'll use SQL*Plus to connect to the database and define a top-level Call Spec for Hello.world():
    SQL> connect scott/tiger
    SQL> create or replace function helloworld return
    VARCHAR2 as language java name 'Hello.world () return
    java.lang.String';
    Function created.
    You can then invoke the Java stored procedure as shown below:
    SQL> variable myString varchar2[20];
    SQL> call helloworld() into :myString;
    Call completed.
    SQL> print myString;
    MYSTRING
    Hello world
    Java stored procedures are callable, through their Call Spec, from SQL DML statements (INSERT, UPDATE, DELETE, SELECT, CALL, EXPLAIN PLAN, LOCK TABLE, and MERGE), PL/SQL blocks, subprograms, and packages, as well as database triggers. The beauty of Call Spec is that stored procedure implementations can change over time from PL/SQL to Java or vice versa, transparently to the requesters.
    Call Spec abstracts the call interface from the implementation language (PL/SQL or Java) and therefore enables sharing business logic between legacy applications and newer Java/J2EE-based applications. At times, however, when invoking a database-resident Java class from a Java client, you may not want to go through the PL/SQL wrapper. In a future release, Oracle plans to provide a mechanism that will allow developers to bypass the Call Spec.
    Advanced Data-Access Control
    Java stored procedures can be used to control and restrict access to Oracle data by allowing users to manipulate the data only through stored procedures that execute under their invoker's privileges while denying access to the table itself. For example, you can disable updates during certain hours or give managers the ability to query salary data but not update it, or log all access and notify a security service.
    Sharing Data Logic Between Legacy and J2EE Applications
    Because legacy applications and J2EE applications both invoke stored procedures through the Call Spec, the same data logic can be shared between J2EE and non-J2EE worlds. Thanks to Call Spec, this data logic can be shared regardless of the implementation language used (whether PL/SQL or Java).
    Autogeneration of Primary Keys for BMP Entity Beans
    When using BMP for EJB entity beans, a bean instance can be uniquely identified by the auto-generated primary key associated with the newly inserted data as a return value for ejbCreate(). You can retrieve this value within ejbCreate() in one database operation by using a stored procedure that inserts the corresponding data and retrieves or computes the primary key. Alternatively, you could insert the data and retrieve the corresponding key (or ROWID) in one SQL statement, using the RETURN_GENERATED_KEYS feature in JDBC 3.0. However, the stored procedure approach is more portable across JDBC driver versions and databases.
    You can implement this pattern with these three steps:
    Create the Java stored procedure, defining a public static Java method insertAccount() within a public GenPK class. This method will insert data, compute a unique key (by passing out a sequence number), and return the computed key as primary key.
    Define the Call Spec.
    CREATE OR REPLACE PROCEDURE insertAccount(owner IN
    varchar, bal IN number, newid OUT number)
    AS LANGUAGE JAVA NAME 'GenPK.insertAccount(
    java.lang.String [])';
    Invoke the stored procedure within ejbCreate().
    Public AccountPK ejbCreate(String ownerName, int balance) throws CreateException
    try {
    CallableStatement call = conn.prepareCall{
    "{call insertAccount(?, ?, ?)}"};          
    return new AccountPK(accountID);
    Custom Primary Key Finders for CMP Entity Beans
    Finder methods are used for retrieving existing EJB entity bean instances. Primary key finders allow you to retrieve a uniquely identified EJB instance. For CMP entity beans, the EJB container automatically generates the primary key finder findByPrimaryKey() method, based on declarative description. In some situations, however, you might need more control; for example, you may need a specialized finder such as findByStoredProcKey(). In these situations, you can use Java stored procedures in conjunction with an object relational framework (such as Oracle9i Application Server [Oracle9iAS] TopLink) to implement a custom primary key finder method. After you define the EJB finder as a REDIRECT or NAMED finder, TopLink will generate the SQL query for retrieving the bean instance.
    Data-Driven EJB Invocation
    In a data-driven architecture, business logic invocation can be triggered as a result of database operations (such as inserts, updates, or deletes). A Java stored procedure implementing the data logic can be declared as a database trigger to invoke EJBs running in a middle-tier J2EE application server. You can make EJB calls by using either standard remote method invocation (RMI) over Interoperable Inter-ORB Protocol (IIOP), using a J2EE 1.3 compatible server, or RMI over a vendor-specific transport protocol (such as ORMI with Oracle9iAS/OC4J or RMI over T3 with BEA WebLogic). Each application server vendor has its own optimized protocol while providing RMI over IIOP for interoperability. Oracle9iAS supports both RMI calls over IIOP and ORMI protocols.
    Data-Driven Messaging
    Oracle9i Database embeds Advanced Queuing (AQ), which is an integrated, persistent, reliable, secure, scalable, and transactional message-queuing framework. Oracle exposes AQ features to Java developers through the standard Java Messaging System (JMS) API. Java stored procedures can invoke AQ operations through the JMS interface to allow fast, intra-session, scalable, data-driven messaging.
    Java stored procedures can use JMS to invoke AQ operations. You can implement this pattern in four steps:
    Create and start the JMS Queue (to do so, embed the following operations within a SQL script):
    execute dbms_aqadm.create_queue_table(queue_table =>
    'queue1', queue_payload_type =>
    'SYS.AQ$_JMS_TEXT_MESSAGE', comment => 'a test queue',
    multiple_consumers => false, compatible => '8.1.0');
    execute dbms_aqadm.create_queue( queue_name => 'queue1',
    queue_table => 'queue1' );
    execute dbms_aqadm.start_queue(queue_name => 'queue1');
    Create the Java stored procedure (a code snippet is shown):
    public static void runTest(String msgBody)
    try
    // get database connection
    ora_drv = new OracleDriver();
    db_conn = ora_drv.defaultConnection();
    // setup sender (cf online code sample)
    // create message
    s_msg = s_session.createTextMessage(msgBody);
    // send message
    sender.send(s_msg);
    s_session.commit();
    // receive message
    r_msg = (TextMessage) receiver.receive();
    r_session.commit();
    // output message text
    String body = r_msg.getText();
    System.out.println("message was '"+body+"'");
    Create the Call Spec:
    create or replace procedure jmsproc (t1 IN VARCHAR)
    as language java name 'jmsSample.main (java.lang.String[])';
    Invoke the stored procedure:
    call jmsproc('hello');
    Database-Assisted Web Publishing (Cache Invalidation)
    One of the common issues application architects must face is how to cache database information reliably to increase overall system performance. JCACHE is an upcoming standard specification (JSR 107) that addresses this problem. It specifies an approach for temporary, in-memory caching of Java objects, including object creation, shared access, spooling, invalidation, and consistency across JVMs. It can be used to cache read-mostly data such as product catalogs and price lists within JSP. Using JCACHE, most queries will have response times an order of magnitude faster because of cached data (in-house testing showed response times about 15 times faster).
    In order to track all the changes to the origin data and refresh the cached data, a Java stored procedure is attached to a table as a trigger. Any change to this table will result in the automatic invocation of this stored procedure, which in turn will call out a defined JSP to invalidate the JCACHE object that maps its state to the database table. Upon invalidation, the very next query will force the cache to be refreshed from the database. Next Steps
    READ MORE about Java Stored Procedures
    This article is adapted from the white paper "Unleash the Power of Java Stored Procedures." You can find the white paper at:
    /tech/java/java_db/pdf/
    OW_30820_JAVA_STORED_PROC_paper.PDF
    New PL/SQL features in Oracle9i Database, Release 2
    /tech/pl_sql/pdf/
    Paper_30720_Doc.pdf
    Resolver Spec
    /docs/products/oracle9i/
    doc_library/release2/java.920/a96659.pdf
    OracleJVM and Java 2 Security
    /docs/products/oracle9i/
    doc_library/release2/java.920/a96656.pdf
    DOWNLOAD Code
    Exercise code examples from this article:
    /sample_code/tech/
    java/jsp/Oracle9iJSPSamples.html
    LEARN about stored procedures as Web services
    /tech/webservices
    Extending Database Functionality
    One of the great things about running Java code directly in the database is the ability to implement new functionality by simply loading the code or library and using the Call Spec to make the entry points (public static methods) available to SQL, PL/SQL, Java, J2EE, and non-Java APIs. Oracle9i Database customers can easily extend database functionality. Oracle itself leverages this capability for new utilities and packages such as the XML Developer Kits (XDKs).
    Bridging SQL, PL/SQL, Java, J2EE, .NET, and XML
    The Oracle XDK is written in Java and exposes its public methods as Java stored procedures, extending the database's XML programmability. SQL, PL/SQL, Java, J2EE, and non-Java (.NET) business logic all have access to the XML parser, the XSLT processor, the XPath engine, and XML SQL Utility (XSU).
    The XML parser is accessible through the xmlparser and xmldom packages. XSU is a Java utility that generates an XML document from SQL queries or a JDBC ResultSet, and writes data from an XML document into a database table or view. Using XSU, XML output can be produced as Text, DOM trees, or DTDs. XSU is exposed to PL/SQL through the dbms_xmlquery and dbms_xmlsave packages.
    Conclusion
    The integration of the Oracle database with a Java VM enables the creation of portable, powerful, database-independent data logic and persistence logic. The loose coupling of business logic that runs in the middle tier with data logic that runs in the database tier improves application scalability, performance, flexibility, and maintenance.
    Kuassi Mensah ([email protected]) is a product manager in the Server Technologies division at Oracle.
    http://otn.oracle.com/oramag/oracle/03-jan/o13java.html
    Joel Pérez

  • Xml in pl/sql

    i want 2 create an xml using pl/sql. oracle web agent must be installed and and xml utilities for pl/sql
    im using win2000 and im connected to ora8.1.6
    in linux. where do i need to install this 2 software. in the server or in my client pc?
    thanks in advance.
    regards
    jerome

    You should install the XML SQL Utility for PL/SQL in your database. It is basically a set of JAVA classes that get loaded into the database. You will use the PL/SQL packages to access the methods on these classes. You should use the DBMS_XMLQUERY and DBMS_XMLSAVE packages.
    You can run the install from your client.

  • Information composer - possible to load to existing table?

    Hi
    Is it possible to use SAP Hana Information Composer to load data to an existing table inside Hana? All the scenarios i have seen are based on creating new tables based on Excel files.
    Kind regards
    Erik

    You can use the DBMS_XMLQuery and DBMS_XMLSave.

  • Questin on query

    hi all,
    how to transfer data between xml file and oracle
    thanks
    pavani

    You should use dbms_xmlquery package that is part of oracle. You can refer on how to use this package from the otn documentation for dbms_xmlquery and dbms_xmlsave. It helps load the xml as well as query the xml as a table output which you can insert into your desired table.
    there are tons of sites that have examples. Just google for it. there is a lot to write .. Hoep I gave you a head start.
    --Samson                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Oracle and XML

    Hi All,
    I have been using Oracle for years, but I am new to processing XML from within Oracle PL/SQL procedure. I have done some research and found that the following packages are useful:
    A) To generate XML from a sql query; (i) DBMS_XMLQUERY and (ii) DBMS_XMLGEN
    B) For Inserting data from an XML document; (i) DBMS_XMLSAVE and (ii) DBMS_XMLSTORE
    Now since I have no experience of using these packages before, I wanted to know which one of the 2 packages for each purpose is best and is normally used? that is, For (A) should I use (i) or (ii), similarly for (B), should I use (i) or (ii)?
    An early response will be greatly appreciated
    Thanks.

    For (A) should I use (i) or (ii), similarly for (B), should I use (i) or (ii)?ALTER SESSION SET SQL_TRACE=TRUE
    then run trace file through TKPROF & compare the results of each alternative.

  • Which way to go with PL/SQL and XML

    Hi fellows,
    I have a general question to XML on Oracle.
    I read already some parts of the three manuals coming with the online documentation of 9i
    - XML developer kit XDK
    - XML API - XDK and Oracle XML DB
    - XML database developer guide Oracle XML DB.
    Also I wrote already a PL/SQL package using DBMS_XMLGEN to generate XML data from relational Oracle tables.
    Actually I like the simplicity how I can create XML data with this DBMS package but I still missing the features like using a DTD/XML Schema to generate XML data.
    I still don't know what the best way would be to use these features of XML in Oracle.
    Hopefully someone can give me some advise and possibly can point to some code samples so that I can see the proper use of the package.
    How about DBMS_XMLQuery?
    To use this package, would that be the better solution for my problem?
    Any comment much appreciated.
    Thanks
    Fred

    Hi Fred,
    Having written a fair amount of PL/SQL code to generate and process XML in the past years, I can give you my opinion on the matter. If you look at the PL/SQL API's Oracle has been written to handle XML, you will find two types/categories of API's: PL/SQL code based on wrapping java (i.e. DBMS_XMLQUERY) and PL/SQL code based on C (i.e. DBMS_XMLGEN). The first category is usually slower, so I tend to use these only if there are no other options. You can measure execution times by executing the same query using both DBMS_XMLGEN. vs. DBMS_XMLQUERY.
    I usually tend to store xml into relational tables by extracting the xml document in PL/SQL using the functions XMLType data type offers (i.e. extract, existNode, getStringVal, etc) function rather than using DBMS_XMLSTORE for flexibility reason (more control over what's being stored).
    Besides the PL/SQL API's there are some rather neat SQL functions to handle XML (i.e. XMLElement, XMLForest, XMLAgg, XMLAttribute, etc) I like to use to build XML documents that are to complex for DBMS_XMLGEN. But, on the downside, I think these functions might cost considerable amounts of CPU, because behind the scene a DOM-tree is build in the SGA/UGA(?), especially on large XML structures or high concurrency systems. I have not measured this yet, so I say might.
    Further, what I think is lacking from the Oracle API's in general is handing of CDATA sections and the fact that some XML functions default generate "pretty-printing" XML, which can not be switched of as far as I know. In my opinion XML should never be "pretty printed", because XML basically is about data transportation, not about lay-out. CDATA sections are not handled, even worse "<![CDATA[ ]]>" is being escaped (to &lt and &gt) and not properly interpreted when processed back to text.

  • 8i and Advanced Queueing

    Does anyone have any experience with DBMS_AQ on Linux (8i)?
    I have a couple of specific questions.
    Cheers,
    Dave Haas
    null

    DBMS_XMLQUERY and DBMS_XMLSAVE are implemented in Java. Neither are part of XQuery. However XQuery does require the java componant since the XQuery parser is currently written in Java. So while we can execute XQuery without Java we currently cannot parse XQuery statements without Java.
    DBMS_XMLGEN and DBMS_XMLSTORE should be present in XE. They are almost 100% feature equivilant to XMLQUERY and XMLSAVE but are implemented in 'C' rather than java. For XML Generation (XMLQUERY/XMLGEN) you should also consider the SQL/XML operators (XMLElement, XMLAgg, XMLForest, XMLAttributes).

  • Read XML message from a CLOB

    We are currently receiving XML messages from a business partner that goes
    through a transformation/parser first to make sure the xml document was
    in MISMO form (Mortgage Industry Standard Message Organization). Then the
    document is stored in a clob in a table. The document is stored Without
    the tags. We are storing these XML messages into a CLOB datatype for
    later processing. I want to read the CLOB and then parse out the
    individual fields to store into a table. What is the best way to
    accomplish this in PL/SQL? Here is one sample record:
    <MORTGAGEDATA>
    <APPLICATION LoanPurposeType="OTHER">
    <LenderCaseIdentifier>3631681</LenderCaseIdentifier>
    <LendersBranchIdentifier>2966448</LendersBranchIdentifier>
    </APPLICATION>
    <PROPERTY PropertyUsageType="Primary">
    <Address1>1335 test</Address1>
    <City>las cruces</City>
    <State>NM</State>
    <PostalCode>88001</PostalCode>
    </PROPERTY>
    <SUBJECTPROPERTY>
    <SubjectPropertyEstimatedValueAmount>69000</SubjectPropertyEstimatedValueAmount>
    </SUBJECTPROPERTY>
    <BORROWERRECONCILEDLIABILITY LiabilityType="HelocSubjectProperty">
    <LiabilityUnpaidBalanceAmount>0</LiabilityUnpaidBalanceAmount>
    <LiabilityMonthlyPaymentAmount>0</LiabilityMonthlyPaymentAmount>
    </BORROWERRECONCILEDLIABILITY>
    <BORROWERRECONCILEDLIABILITY LiabilityType="MortgageLoanSubjectProperty">
    <LiabilityUnpaidBalanceAmount>0</LiabilityUnpaidBalanceAmount>
    </BORROWERRECONCILEDLIABILITY>
    <BORROWER>
    <FirstName>scooby</FirstName>
    <MiddleName/>
    <LastName>doo</LastName>
    <NameSuffix/>
    <MothersMaidenName>velma</MothersMaidenName>
    </BORROWER>
    </MORTGAGEDATA>
    NOTE: I have tried to use DBMS_XMLQUERY and it comes out like this using a
    stored procedure called printclob: When I do this the data is put into
    one field called xml_app_msg. The problem is how do I reference the
    individual fields like FirstName and so on to store in another table? Can
    I apply a stylesheet and if so, how?
    Or do I create an object type called xml_app_msg with the fields lastname
    and so on?
    -- The table is raw_xml_msg_tbl and the field with the stored infomation is
    xml_app_msg.
    set serveroutput on size 50000
    declare
    queryCtx DBMS_XMLquery.ctxType;
    result CLOB;
    begin
    queryCtx := DBMS_XMLQuery.newContext('select xml_app_msg from raw_xml_msg_tbl where app_id = :APP_ID');
    -- DBMS_XMLQuery.clearBindValue(queryCtx);
    DBMS_XMLQuery.setBindValue(queryCtx,'APP_ID','LT1001');
    -- get the result..!
    result := DBMS_XMLQuery.getXML(queryCtx);
    -- Now you can use the result to put it in tables/send as messages..
    printClobOut(result);
    DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query handle..
    end;
    OUTPUT:
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW num="1">
    <XML_APP_MSG><MORTGAGEDATA>
    <BORROWER>
    <FirstName>Falls</FirstName>
    <MiddleName/>
    <LastName>Water</LastName>
    <NameSuffix/>
    <SSN>123-45-6789</SSN>
    </BORROWER>
    </MORTGAGEDATA>
    </XML_APP_MSG>
    </ROW>
    </ROWSET>
    null

    I parse the XML doc into a domdocument and then loop through using xpath.valueof to pull the individual values from the nodes and then build a generic insert. It works quite well with a small number of columns. I'm not sure how it would work with a lot of columns. You can get code examples from Steve Muench's book "Developing Oracle XML Applications".

  • Generating multi-level xml in oracle

    Hi,
    I want to create a multi-level XML structure from oracle, is there a way?
    Presently oracle provides DBMS_XMLQUERY and XMLGEN package to generated XML structure given a query. But the structure so generated is of single level. That is say I use
    select XMLGEN.getXML('select * from employees') from dual;
    the output is
    <EMPLOYEE>
    <ROW num="1">
    <NAME>Mark</NAME>
    <TEL>451-638191</TEL>
    </ROW>
    </EMPLOYEE>
    That I call a single level output.
    To create a multiple level XML I went in for object type in oracle. But the problem with this is that if I want to have multiple children for a single parent then object types fail. The structure below is not possible with object type.
    <EMPLOYEE>
    <ROW num="1">
    <NAME>Mark</NAME>
    <CONTACT>
    <ROW>
    <RESIDENCE>
    <ADDRESS>
         <ROW>
         Fifth Avenue, New York
         </ROW>
    </ADDRESS>
    <TEL>
         <ROW>451-638191</ROW>
         <ROW>451-638192</ROW>
         <ROW>451-638193</ROW>
    </TEL>
    </RESIDENCE>
    </ROW>
    <ROW>
    <RESIDENCE>
    <ADDRESS>
         <ROW>
         Fouth Avenue, New York
         </ROW>
    </ADDRESS>
    <TEL>
         <ROW>452-638191</ROW>
         <ROW>452-638192</ROW>
         <ROW>452-638193</ROW>
    </TEL>
    </RESIDENCE>
    </ROW>
    </CONTACT>
    </ROW>
    </EMPLOYEE>
    Then I tried nested tables. Here one needs to create an object type to create a table type. One cannot create a table type out of another table type. So that leavs me with 2 levels
    object type
    used by
    table type
    used by
    table.
    Presently to generated a multi-level output as shown above I'm using cursors and build it in a clob variable.
    Is there any other way that one can build a multi-level structure. Or is there a build in package that comes with orace 8i (and higher).
    Regards,
    Milton.

    Milton,
    I was able to generate hierarchical XML from Oracle using object views and XML-SQL Utility (XSU).
    Here is a simplified version of my OR schema:
    /* Physical spec object */
    create or replace type physical_specifications_object as object (
    physical_specifications_id number(15),
    page_count number(10),
    product_id number(10),
    four_color_count number(10),
    two_color_count number(10),
    table_count number(10),
    binding_type varchar2(100),
    height varchar2(20),
    width varchar2(20)
    /* Market object */
    create or replace type market_object as object (
    market_id number(15),
    master_class_name varchar2(50),
    market_name varchar2(100),
    market_type varchar2(100),
    market_description varchar2(500),
    level_rank varchar2(15),
    market_code varchar2(100),
    product_id number(10)
    /* List of markets */
    create or replace type market_table as table of market_object;
    /* Market object view */
    create or replace view market_object_view of market_object
    with object identifier (market_id) as
    select mkt.market_id,
    class.master_class_name,
    mkt.market_name,
    mkt.market_type,
    mkt.market_description,
    prod_mkt.level_rank,
    mkt.market_code,
    p.product_id
    from market mkt,
    product p,
    product_market prod_mkt,
    master_class class
    where p.product_id = prod_mkt.product_id
    and prod_mkt.market_id = mkt.market_id
    and mkt.master_class_id = class.master_class_id(+);
    /* Feature object */
    create or replace type product_feature_object as object (
    feature_id number(15),
    feature_text varchar2(3500),
    feature_type varchar2(100)
    /* List of features */
    create or replace type product_feature_table as table of product_feature_object;
    /* Product object */
    create or replace type product_object as object (
    product_id number(10),
    title varchar2(150),
    media_type varchar2(20),
    standard_number varchar2(100),
    physical_specifications physical_specifications_object,
    markets market_table,
    product_features product_feature_table
    /* Product object view */
    create or replace view product_object_view of product_object
    with object identifier (product_id) as
    select p.product_id,
    p.title,
    p.media_type,
    p.standard_number,
    physical_specifications_object(spec.physical_specifications_id,
    spec.page_count,
    spec.product_id,
    spec.four_color_count,
    spec.two_color_count,
    spec.table_count,
    spec.binding_type,
    spec.height,
    spec.width),
    cast(multiset(select *
    from market_object_view mkt
    where mkt.product_id(+) = p.product_id) as market_table) as markets,
    cast(multiset(select f.feature_id, f.feature_text, f.feature_type
    from feature f
    where f.product_id = p.product_id) as product_feature_table) as product_features
    from product p,
    physical_specifications spec
    where p.product_id = spec.product_id(+)
    The objective is to generate XML for a product list with all the product subelements. The simple query "select * from product_object_view" when fed to the XML-SQL utility generates multi-level SQL. Note that Oracle 8i allows up to two level collection nesting in object types. Oracle 9i removes this limitation.
    Check XSU documentation at http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/xsu/xsu_userguide.html#1014886
    Hi,
    I want to create a multi-level XML structure from oracle, is there a way?
    Presently oracle provides DBMS_XMLQUERY and XMLGEN package to generated XML structure given a query. But the structure so generated is of single level. That is say I use
    select XMLGEN.getXML('select * from employees') from dual;
    the output is
    <EMPLOYEE>
    <ROW num="1">
    <NAME>Mark</NAME>
    <TEL>451-638191</TEL>
    </ROW>
    </EMPLOYEE>
    That I call a single level output.
    To create a multiple level XML I went in for object type in oracle. But the problem with this is that if I want to have multiple children for a single parent then object types fail. The structure below is not possible with object type.
    <EMPLOYEE>
    <ROW num="1">
    <NAME>Mark</NAME>
    <CONTACT>
    <ROW>
    <RESIDENCE>
    <ADDRESS>
         <ROW>
         Fifth Avenue, New York
         </ROW>
    </ADDRESS>
    <TEL>
         <ROW>451-638191</ROW>
         <ROW>451-638192</ROW>
         <ROW>451-638193</ROW>
    </TEL>
    </RESIDENCE>
    </ROW>
    <ROW>
    <RESIDENCE>
    <ADDRESS>
         <ROW>
         Fouth Avenue, New York
         </ROW>
    </ADDRESS>
    <TEL>
         <ROW>452-638191</ROW>
         <ROW>452-638192</ROW>
         <ROW>452-638193</ROW>
    </TEL>
    </RESIDENCE>
    </ROW>
    </CONTACT>
    </ROW>
    </EMPLOYEE>
    Then I tried nested tables. Here one needs to create an object type to create a table type. One cannot create a table type out of another table type. So that leavs me with 2 levels
    object type
    used by
    table type
    used by
    table.
    Presently to generated a multi-level output as shown above I'm using cursors and build it in a clob variable.
    Is there any other way that one can build a multi-level structure. Or is there a build in package that comes with orace 8i (and higher).
    Regards,
    Milton.

  • Oracle AQ, the Advanced Queueing Facility

    Hi all,
    Does someone have first hand experience using
    Oracle AQ, the Advanced Queueing Facility?
    I am primarily interested in understanding its reliability, usability and general industry acceptance.
    thx
    Kalpana Subramanian

    DBMS_XMLQUERY and DBMS_XMLSAVE are implemented in Java. Neither are part of XQuery. However XQuery does require the java componant since the XQuery parser is currently written in Java. So while we can execute XQuery without Java we currently cannot parse XQuery statements without Java.
    DBMS_XMLGEN and DBMS_XMLSTORE should be present in XE. They are almost 100% feature equivilant to XMLQUERY and XMLSAVE but are implemented in 'C' rather than java. For XML Generation (XMLQUERY/XMLGEN) you should also consider the SQL/XML operators (XMLElement, XMLAgg, XMLForest, XMLAttributes).

  • Update the passed XML in a PL/SQL procedure and then use DBMS_XMLSAVE

    hi folks,
    This is a great forum and most of you guys were awesome in replying to complex queries........
    I have a small issue, I am trying to do a bulk insert from my application by constructing an XML result set and pass that XML to the SP as a CLOB and using DBMS_XMLSAVE package to insert it to the oracle table. It works like a charm for me when this is as straight forward as this. But when my requirement is, I need to generate sequence numbers for a particular column (Primary key column), while for other columns I pass values from the UI (as a XML object which my SP accepts as a CLOB), i am at a loss for solution to achieve this. It would mean, that I have to generate the sequence numbers for each row and then update this value to the passed XML clob. Any indicators on how to achieve this?
    I found this solution at one of the thread which might most probably help me,
    declare
    2 l_cnt number;
    3 begin
    4 select count(*) into l_cnt from books,xmltable('/Books/Book' passing object_value);
    5 for i in 1..l_cnt loop
    6 update books set object_value =
    7 updatexml(object_value,'/Books/Book['||i||']/BookID', xmlelement("BookID",sequence_bookid.nextval))
    8 where existsnode(object_value,'/Books/Book['||i||']')=1;
    9 end loop;
    10 end;
    11 /
    But here, they are trying to update a XMLTable book, but in my case the XML is a clob object and not a XML table. Will this solution work for my case as well? Please provide any pointers to me... Thanks...

    First if your version of Oracle has DBMS_XMLSTORE, use that instead.
    Reason: {thread:id=876376} (See Marco's response).
    It is possible you could run into issues, but you should start with DBMS_XMLSTORE.
    Since you will have the XML in the SP, treat the data as an XMLType instead of a CLOB for as long as you can since you need to do UpdateXML on it.
    For your sample PL/SQL code, lines 4-5 are replaced with the WHILE loop shown in Method 2 at
    {message:id=3610259}.
    The UPDATE would be replaced with the following pseudocode
    SELECT UPDATEXML(<l_xmltype_variable>, ...)
    INTO <l_xmltype_variable>
    FROM dual;
    Once your loop is done, l_xmltype_variable would contain your updated XML and then you can use that XMLType directly on the call to DBMS_XMLSTORE or convert it back to a clob via
    l_clob_variable := l_xmltype_variable.getClobVal();

Maybe you are looking for

  • Kern protection error from Call of Duty 2 game

    Hey everyone,  I was told if anyone could help me it would be on here. Over the last few weeks I started getting the odd kern protection error while playing my Call of Duty 2 game.  I have had this game for years and this had never happened before. O

  • Deleted iphoto library - recovered library not photos help

    I was trying to clean up the photos in my Picture folder and accidentally deleted the library folder. I have recovered the folder but not the pictures. How do I get the pictures back? I opened iphoto and was asked about a library so I checked the lib

  • Is it possible to change an attribute of image using VB?

    hello everyone!, I just want to ask if it's possible to add an attribute to a image using Visual basic. and the image will save as jpeg file together with the add attribute to the properties? by the way, I am john. freshman college student from phil.

  • Accidently remove oracle_home software, instance is down, how to do?

    Hi, I have a quick question, when using installer uninstall(remove) oracle software, selected wrong oracle home, then removing process only happens for 1 sencond (stop almost immediately), the instance still crashed down. how to bring up the instance

  • HELP! flash stops working when I want to import a sequence of images to stage

    Please! I need help asap! I downloaded Flash CS5 and I am using it as a trial and every time I want to import a sequence of images to stage the program stops working and closes without saving. I need to do this projecto for the day after tomorrow and