Xmlelement name

Hi ,
i want to generate xml using xmlelement.
but the name (i.e string to be inserted as a tag) has a length more than 30.
So i am getting an error.
Can anyone suggest me how to get a tag with length more than 30 while using
XMLElement function.
Example:
1) Executes without any errors:
select distinct xmlelement("empdetails",
xmlelement("deptno",d.deptno),
(select xmlagg(xmlelement("emp",
xmlelement("012345678901234567890123456789",e.empno),
xmlelement("ename",e.ename)
from emp e
where e.deptno=d.deptno
)).extract ('/*').getStringVal() AS xml_row
from emp d;
2) This one gives the error: (length of tag for e.empno is 31)
select distinct xmlelement("empdetails",
xmlelement("deptno",d.deptno),
(select xmlagg(xmlelement("emp",
xmlelement("0123456789012345678901234567890",e.empno),
xmlelement("ename",e.ename)
from emp e
where e.deptno=d.deptno
)).extract ('/*').getStringVal() AS xml_row
from emp d
error:ORA-00972: identifier is too long
Regards,
Ravi Kumar M
Message was edited by:
[email protected]

Any work arounds please ...
is it a limitation of xmlelement function ??

Similar Messages

  • Oracle.xml.sql.OracleXMLSQLException: Expected name instead of .

    Hi,
    I'm using XDK in Tomcat to execute queries and get the XML result in the browser. I have written many queries but now I'm having problems in one of them.
    The error output that I see in my browser is this one:
    <ROOT>
    <ERROR>
    oracle.xml.sql.OracleXMLSQLException: Expected name instead of <.
    </ERROR>
    </ROOT>:
    This error message is known as XML-20126 but it's not documented in the XML Developer's Kit Programmer's Guide, so I don't know what to do.
    My XSQL query is the following:
    <ROOT connection="xxxx_read" xmlns:xsql="urn:oracle-xsql">
    <xsql:query>
    SELECT XMLAGG(XMLELEMENT("NODE",
    XMLELEMENT("name", b.nodename),
    (SELECT XMLAGG(XMLELEMENT("SERVICE",
    XMLATTRIBUTES(a.serviceabbr AS "type")
    ORDER BY a.serviceabbr
    FROM service a, serviceinstance c
    WHERE c.isdeleted='N'
    AND a.serviceid=c.serviceid
    AND c.nodeid=b.nodeid
    ORDER BY b.nodename
    ) AS "NODES"
    FROM node b
    WHERE b.isdeleted='N'
    </xsql:query>
    </ROOT>
    That query executes fine in sqlplus, where I can see the XML result.
    I think my problem could be related to the size of the XML output. In sqlplus, the output has around 38000 bytes size, which is nothing, so I don't really know why that should be a problem. Do you have any idea?
    Thanks for your help,
    David

    So it seems there is a problem in fact:
    XDB FUNCTION RESULTS ARE TRUNCATED WHEN USING XSQL
    *** 02/25/04 08:28 am ***
    Problem Description
    There appears to be a limit on the content or characters that XSQL pages
    handle when being passed data from XDB functions such as XMLAGG() and
    XMLELEMENT().
    If you have a xsql page of the form
    < ?xml version="1.0"?>
    < xsql:query xmlns:xsql="urn:oracle-xsql" connection="demo" >
    select XMLAgg(XMLElement("Test", XMLAttributes(i.id as "Id_van_de_test",
    i.name as "Name_van_de_test"))) as "Tests" from problem_xml i
    < /xsql:query>
    If the number of rows (or amount of data) in the table is low, the result
    appears okay. However, if the data returned is large the data appears to
    truncate giving xml parsing errors as if the xml returned is not well formed.
    In the testcase provided, the error is as follows :-
    Results from 10.1.0.2
    < Line 2, Column 16354>: XML-20126: (Fatal Error) '< ' cannot appear in attribute value.
    < Line 2, Column 16366>: XML-20190: (Fatal Error) Whitespace required.
    < Line 2, Column 16366>: XML-20201: (Fatal Error) Expected name instead of 4.
    < ?xml version = '1.0'?>
    value.< /ERROR>
    Results from 9.2.0.6
    < Line 2, Column 16354>: XML-0126: (Fatal Error) '< ' cannot appear in attribute value.
    < Line 2, Column 16368>: XML-0190: (Fatal Error) Whitespace required.
    < Line 2, Column 16368>: XML-0201: (Fatal Error) Expected name instead of 3.
    < Line 2, Column 16371>: XML-0122: (Fatal Error) '=' missing in attribute.
    < Line 2, Column 16391>: XML-0190: (Fatal Error) Whitespace required.
    < Line 2, Column 16396>: XML-0122: (Fatal Error) '=' missing in attribute.
    < Line 2, Column 16397>: XML-0125: (Fatal Error) Attribute value should start with quote.
    < ?xml version = '1.0'?>
    value.< /ERROR>
    And the workaround:
    ======================================================
    The only workaround we have is to get the Document generated using
    DBMS_XMLQUERY [with expanded entities].
    _==Start===
    create or replace procedure Query2XML(QueryString varchar2 default
    'select col1 from xml_tab where r_id = ?') IS
    XMLCtx number;
    myXML clob;
    myXMLLength number;
    BEGIN
    XMLCtx := DBMS_XMLQUERY.NEWCONTEXT(QueryString);
    myXML := DBMS_XMLQUERY.GETXML(XMLCtx);
    myXMLLength := DBMS_LOB.GETLENGTH(myXML);
    DBMS_XMLQUERY.CLOSECONTEXT(XMLCtx);
    END Query2XMLFile;
    _==Start===
    Currently, XDB uses a DOM based model for XSLT evaluation. It is not
    possible to support disable-output-escaping constructs through this
    evaluation. This might be supported in a future release when a different
    model is implemented.
    =============================================================

  • Availability of the SQL/XML functions (XMLELEMENT, etc.) in Oracle 10g XE

    Hi,
    I have installed Oracle 10g XE on a Windows PC. According to the Oracle XML DB Developer's Guide p.2-1, the installation of the Oracle XML DB can be checked via the following commands:
    select * from all_users;
    describe resource_view
    I ran both commands and got the desired output according to the Developer's guide, i.e.: The user XDB exists and so does the view resource_view. However, when I ran a small test with the XMLELEMENT function, then I got unsatisfactory results:
    Example:
    SELECT
    XMLELEMENT (
    NAME Land,
    XMLATTRIBUTES (L.LCode AS LCode),
    XMLELEMENT (NAME LName, L.LName)
    ) AS Mondial
    FROM Land L;
    Output on Oracle 10g XE:
    MONDIAL
    SYS.XMLTYPE
    SYS.XMLTYPE
    SYS.XMLTYPE
    SYS.XMLTYPE
    Expected output (which I got from a successful run on an Oracle 10g EE Server):
    MONDIAL
    <LAND LCODE="A "><LNAME>Austria</LNAME></LAND>
    <LAND LCODE="F "><LNAME>France</LNAME></LAND>
    <LAND LCODE="D "><LNAME>Germany</LNAME></LAND>
    <LAND LCODE="I "><LNAME>Italy</LNAME></LAND>
    i.e., rather than the four XML elements, I just got four times the output sys.xmltype - which is of course useless. What can I do to get the desired output? Thank you for your help.
    Reini, user524179

    What program are you using to run the sql? Are you sure you are using sql*plus for getting this?
    Output on Oracle 10g XE:
    MONDIAL
    SYS.XMLTYPE
    SYS.XMLTYPE
    SYS.XMLTYPE
    SYS.XMLTYPE

  • Unexpected result from XMLELEMENT() - nothing but XMLTYPE()

    In testing XML DB thru SQL*PLUS under an Oracle 9.2 environment, I issued following query:
    <QueryStatement>
    SELECT XMLELEMENT("Name", p.name) as "Result" FROM PROD_PERIODS p
    </QueryStatement>
    But it returned nothing but following message that contain only "XMLTYPE()":
    <ReturnedMessage>
    Result()
    XMLTYPE()
    XMLTYPE()
    </ReturnedMessage>
    The table PROD_PERIODS does contain data for the test, which has been proved by removing the XMLELEMENT() function call.
    Is there any setting should have been done before hand?
    Any hints will be highly appreciated!
    Thanks!
    Spenser

    Hi Mark,
    Thanks for the hint and yes you're right the SQL*PLUS I was using, v8.1.7, is not XML aware.
    Regards,
    Spenser

  • XmlElement  Input Parameter to the webmethod.

    Here is the WSDL Snippet.
    <s:element name="RegisterService">
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="InputElement">
    <s:complexType>
    <s:sequence>
    <s:any />
    </s:sequence>
    </s:complexType>
    </s:element>
    </s:sequence>
    </s:complexType>
    </s:element>
    The web service method input parameter is defined as an XmlElement in the .Net Environment
    public XmlElement RegisterService(XmlElement InputElement)
    How the InputElement will be put in the Java Client Code. Please provide how to proceed for the Client side code for calling the RegisterService method.
    Regards \
    Pramod

    Here is the Client Code generated for the web service i need to build the client for.
    How do i make the method call with the InputElement for the RegisterInput .
    package com.test.webservices;
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAnyElement;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlType;
    * <p>Java class for anonymous complex type.
    * <p>The following schema fragment specifies the expected content contained within this class.
    * <pre>
    * &lt;complexType>
    * &lt;complexContent>
    * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    * &lt;sequence>
    * &lt;element name="InputElement" minOccurs="0">
    * &lt;complexType>
    * &lt;complexContent>
    * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    * &lt;sequence>
    * &lt;any/>
    * &lt;/sequence>
    * &lt;/restriction>
    * &lt;/complexContent>
    * &lt;/complexType>
    * &lt;/element>
    * &lt;/sequence>
    * &lt;/restriction>
    * &lt;/complexContent>
    * &lt;/complexType>
    * </pre>
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
    "inputElement"
    @XmlRootElement(name = "RegisterInput")
    public class RegisterInput {
    @XmlElement(name = "InputElement")
    protected RegisterInput.InputElement inputElement;
    * Gets the value of the inputElement property.
    * @return
    * possible object is
    * {@link RegisterInput.InputElement }
    public RegisterInput.InputElement getInputElement() {
    return inputElement;
    * Sets the value of the inputElement property.
    * @param value
    * allowed object is
    * {@link RegisterInput.InputElement }
    public void setInputElement(RegisterInput.InputElement value) {
    this.inputElement = value;
    * <p>Java class for anonymous complex type.
    * <p>The following schema fragment specifies the expected content contained within this class.
    * <pre>
    * &lt;complexType>
    * &lt;complexContent>
    * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    * &lt;sequence>
    * &lt;any/>
    * &lt;/sequence>
    * &lt;/restriction>
    * &lt;/complexContent>
    * &lt;/complexType>
    * </pre>
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
    "any"
    public static class InputElement {
    @XmlAnyElement(lax = true)
    protected Object any;
    * Gets the value of the any property.
    * @return
    * possible object is
    * {@link Object }
    public Object getAny() {
    return any;
    * Sets the value of the any property.
    * @param value
    * allowed object is
    * {@link Object }
    public void setAny(Object value) {
    this.any = value;
    }

  • Global Type declaration/definition of name duplicated error

    Hi, All,
    We have two EJB exposed as the Webservice , so WS-1 and WS2, When I insert these two WS into the SOA Application to used by BPEL process. I get the compile error from jdev(11.1.1.1.3) like this:
    Global Type declaration/definition of name '{http://mynamespace-here/oracle}SearchParameter' are duplicated at the following locations:
    EJB WS1 xsd line ***
    EJB WS2 xsd line ***
    SearchParameter is bean SearchRequest‘s property, this bean is shared using in two EJB method interfaces.
    Our class design like this:
    @XmlRootElement
    @XmlType(name = "SearchRequest",
    namespace = " http://mynamespace-here/oracle ")
    public class SearchRequest
    implements Serializable
    private SearchInterface searchCriteria;
    @XmlElements(value =
    { @XmlElement(name = "SearchParameter",
    type = SearchParameter.class) })
    public SearchInterface getSearchCriteria()
    return searchCriteria;
    At here SearchInterface is an empty interface and SearchParameter is a class implement this interface.
    I feel @XmlElement in fact cause this duplicated error.
    So in this case, how can we expose this SearchInterface/SearchParameter through the XML properly?
    Thanks .
    wayne
    Edited by: user782942 on Feb 8, 2011 11:37 PM

    If the message type in the external service and the one using in your local are using the same schema, could you check whether the external service has changed the schema in any way? Adding new fields, changing the field name, or changing the namespace? We had faced this issue before, and it was because the schema in our mds is different from the schema from OSB, which they changed it after we get the artifacts and we didn't have the updated schema in our mds.

  • SQLX FUNCTIONS, XMLELEMENT()

    My SQL Query uses SQL XML functions such as XMLElement(). My XML Publisher report was running perfectly until we upgraded the database to version 10.2.0.2, plus we are using RAC.
    When I run the query using SQL Developer I get data correctly output within elements, but as soon as I test it in XML Publisher it does not return the XML elements from my XMLElement() output.
    This is a simple example that doesn't return data via a SQL Query in XML Publisher:
    select xmlelement("abc", xmlelement("xyz", 'test')).getClobVal() AS test
    from dual
    Output:
    <ROWSET>
    <ROW>
    <TEST />
    </ROW>
    </ROWSET>
    From SQL Developer this is the correct output I get:
    <abc><xyz>test</xyz></abc>
    Out version of XML Publisher is Standalone 5.6.2 and our clustered Application Server version is 10.1.2.
    Thanks in advance for any help.

    This is what I've got;
    SQL> set serveroutput on
    SQL> declare
    2 x xmltype;
    3 begin
    4 select xmlelement("name",'coby') into x from dual;
    5 dbms_output.put_line(x.getClobVal());
    6 end;
    7 /
    select xmlelement("name",'coby') into x from dual;
    ERROR at line 4:
    ORA-06550: line 4, column 10:
    PLS-00201: identifier 'XMLELEMENT' must be declared
    ORA-06550: line 4, column 3:
    PL/SQL: Statement ignored
    declare
    x xmltype;
    begin
    select xmltype('<Name first="Mark" last="Drake"/>') into x from dual;
    dbms_output.put_line(x.getClobVal());
    end;
    works to no surprise ->
    <Name first="Mark" last="Drake"/>
    declare
    x xmltype;
    a varchar2(20);
    begin
    x := xmltype('<Name first="Mark" last="Drake"/>');
    select extractValue(x,'/Name/@last') into a from dual;
    dbms_output.put_line(a);
    end;
    ERROR at line 6:
    ORA-06550: line 6, column 8:
    PLS-00201: identifier 'EXTRACTVALUE' must be declared
    ORA-06550: line 6, column 1:
    PL/SQL: Statement ignored
    declare
    d varchar2(20);
    begin
    select to_char(sysdate,'YYYY-MM-DD') into d from Long postings are being truncated to ~1 kB at this time.

  • Select XMLElement - want some whitespace or newlines!

    Hi -
    I'm using XML SQL psuedo functions to make an XML document. It's making valid XML, but it's hideous to read. The SQL select is actually a select ... into in a PL/SQL function. Is there any way to force some newlines or spaces after the end tags, so the message would be more readable in a text editor?
    EXAMPLE:
    SELECT XMLElement("OBSERVATION-DATA",
         XMLAttributes('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",
              'C:\Documents and Settings\rmercer\My Documents\Rick\projects\LAPHIN\Maps\canonical_v2\canonical_lab_v3.xsd' AS "xsi:noNamespaceSchemaLocation"),
    XMLForest(
         XMLForest(
              c_SOURCEEXT     as "SOURCE-IDENT",
              c_SOURCEROOT     as "SOURCE-ROOT",
              c_SOURCEEXT     as "SOURCE-FACILITY-IDENT",
              c_SOURCEROOT     as "SOURCE-FACILITY-ROOT",
              ) as "SOURCE-INFORMATION", -- end of source info forest
         XMLForest(
              XMLConcat( XMLElement("PERSON-ID-NUMBER", MPERSON.PERSON_UID),
         ) -- end of main forest
         ) into v_OBSXML
    FROM nbs_msgine.msgin_person MPERSON,
    GIVES A REALLY LONG LINE OF OUTPUT:
    <SOURCE-INFORMATION><SOURCE-IDENT>LABCORP</SOURCE-IDENT><SOURCE-ROOT>999.5.1.2.1</SOURCE-ROOT><SOURCE-FACILITY-IDENT>LABCORP</SOURCE-FACILITY-IDENT><SOURCE-FACILITY-ROOT>999.5.1.2.1</SOURCE-FACILITY-ROOT><RECVR-IDENT>LADOH</RECVR-IDENT><RECVR-ROOT>999.5.1.1.5</RECVR-ROOT><RECVR-FACILITY-IDENT>LADOH</RECVR-FACILITY-IDENT><RECVR-FACILITY-
    Thanks!
    Andy Russo

    The SQL/XML functions do not pretty-print for performance reasons. Over a large document the amount of additional white space generated by pretty printing can be quite expensive.
    There is a very simple way of forcing a pretting print
    As can be seen in the example below the output is not pretty printed. It's technically correct but difficult to read.
    SQL> select xmlElement
    2 (
    3 "Country",
    4 xmlElement("Name",c.COUNTRY_NAME),
    5 xmlAgg
    6 (
    7 xmlElement
    8 (
    9 "Department",
    10 xmlElement("Name", d.DEPARTMENT_NAME),
    11 ( select xmlAgg
    12 (
    13 xmlElement
    14 (
    15 "Employee",
    16 xmlForest(e.FIRST_NAME as "FirstName", e.LAST_NAME as "LastName")
    17 )
    18 )
    19 from HR.EMPLOYEES e
    20 where e.DEPARTMENT_ID = d.DEPARTMENT_ID
    21 )
    22 )
    23 )
    24 ) as XML
    25 from HR.COUNTRIES c, HR.DEPARTMENTS d, HR.LOCATIONS l
    26 where l.COUNTRY_ID = c.COUNTRY_ID
    27 and d.LOCATION_ID = l.lOCATION_ID
    28 and c.COUNTRY_NAME = 'Canada'
    29 group by c.COUNTRY_NAME
    30 /
    <Country><Name>Canada</Name><Department><Name>Marketing</Name><Employee><FirstNa
    me>Michael</FirstName><LastName>Hartstein</LastName></Employee><Employee><FirstN
    ame>Pat</FirstName><LastName>Fay</LastName></Employee></Department></Country>
    In order to get pretty printed output we need to force a print & parse. It should be remembered that this is fairly expensive and so should only be done when debugging out etc. It can be done by adding .extract('/*') to the output of the outermost SQL/XML operator.
    Eg
    SQL> select xmlElement
    2 (
    3 "Country",
    4 xmlElement("Name",c.COUNTRY_NAME),
    5 xmlAgg
    6 (
    7 xmlElement
    8 (
    9 "Department",
    10 xmlElement("Name", d.DEPARTMENT_NAME),
    11 ( select xmlAgg
    12 (
    13 xmlElement
    14 (
    15 "Employee",
    16 xmlForest(e.FIRST_NAME as "FirstName", e.LAST_NAME as "LastName")
    17 )
    18 )
    19 from HR.EMPLOYEES e
    20 where e.DEPARTMENT_ID = d.DEPARTMENT_ID
    21 )
    22 )
    23 )
    24 ).extract('/*') as XML
    25 from HR.COUNTRIES c, HR.DEPARTMENTS d, HR.LOCATIONS l
    26 where l.COUNTRY_ID = c.COUNTRY_ID
    27 and d.LOCATION_ID = l.lOCATION_ID
    28 and c.COUNTRY_NAME = 'Canada'
    29 group by c.COUNTRY_NAME
    30 /
    <Country>
    <Name>Canada</Name>
    <Department>
    <Name>Marketing</Name>
    <Employee>
    <FirstName>Michael</FirstName>
    <LastName>Hartstein</LastName>
    </Employee>
    <Employee>
    <FirstName>Pat</FirstName>
    <LastName>Fay</LastName>
    </Employee>
    </Department>
    </Country>

  • Request: Report queries should treat a xmltype column as a xmlelement

    In the shared components you can define a report query for creating PDF reports for example.
    APEX will transform the results of the defined sql query to xml on runtime.
    Each column of the query becomes a xmlelement. The values of the column will be the text data of the xmlelement.
    In the current APEX versions a xmltype column in the sql query is not supported sadly enough.
    I would like to see that if a column is a xmltype that APEX treats its values as a xmlelement and not as text.
    This way it makes it possible to construct more meaningful xml structures using sqlx functions (xmlelement, xmlagg, etc...)
    For example:
    Report query
    select xmlelement("USER",xmlattributes(u.user_id as "ID")
    ,xmlelement("NAME",u.username)) users
    from all_users u
    where rownum < 3
    will now be transformed in
    <?xml version="1.0" encoding="UTF-8"?>
    <ROWSET>
    <ROW>
    <USERS>[unsupported data type]</USERS>
    </ROW>
    <ROW>
    <USERS>[unsupported data type]</USERS>
    </ROW>
    </ROWSET>
    It should be:
    <?xml version="1.0" encoding="UTF-8"?>
    <ROWSET>
    <ROW>
    <USERS>
    <USER ID="0">
    <NAME>SYS</NAME>
    </USER>
    </USERS>
    </ROW>
    <ROW>
    <USERS>
    <USER ID="5">
    <NAME>SYSTEM</NAME>
    </USER>
    </USERS>
    </ROW>
    </ROWSET>
    Or make it an option that it is possible to define a xml query instead of a sql query.
    APEX doesn't have transform the query results in to xml on runtime, because the result is already a xml.
    For example:
    XML query
    select sys_xmlagg (sys_xmlgen (xmlelement ("USERS"
    ,xmlelement ("USER"
    ,xmlattributes (u.user_id as "ID")
    ,xmlelement ("NAME"
    ,u.username)))))
    users
    from all_users u
    where rownum < 3
    results in:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <USERS>
    <USER ID="1">
    <NAME>SYS</NAME>
    </USER>
    </USERS>
    </ROW>
    <ROW>
    <USERS>
    <USER ID="5">
    <NAME>SYSTEM</NAME>
    </USER>
    </USERS>
    </ROW>
    </ROWSET>

    Thank you for a quick response, but I am really surprised/confused by your answer.
    User-agent already reports operating system. Adding the width/height of the device is not really any more private than that and is definitely not a personally identifiable information. What does it have to do with privacy?
    We are not asking to report any device capability that Javascript does not already have access to. So if somebody wanted to gather the information s/he could already gather it by making an Ajax request through Javascript. The only difference is: that won't help images or Responsive Web efforts in a clean way.
    Bottomline: this information is already available and is not of a Private Identifiable category. We just need to make it available in a manner in which it can be used for good.

  • Display column name with Group by

    Hi,
    I am having a table with a column series which is repeating.
    When i want to get all the unique series and its count, in the normal sql, I am using
    select series,count(1) from temp_table group by series;
    But the same is not working in the case of SQLX,
    I want <root><series><name count="8">series1</name><name count="18">series2</name></series></root> kind of output.
    But when i use SQLX query,
    select XMLElement("root",XMLElement("series",XMLAgg(XMLElement("name", ... group by series
    it is returning more than one record.
    How to get the desired result??
    Thanks
    Guru

    I wanted to know whether it is possible to get the count in the sqlx itself, Can anybody point me to any SQLX query for that?

  • JDBC AND XML return null result

    i am using this java code through Java concurrent program and i want to print xml in my screen.
    it's showing null but when i run this query in sql developer it's showing xml.
    String lQuery2 = " select xmlelement(\"user\", " +
    " xmlagg( " +
    " xmlelement(\"name\",user_name) " +
    " ) "+
    " ) as users " +
    " from apps.fnd_user " +
    " where user_id in (100001,100002)";
    PreparedStatement lStmt = mJConn.prepareStatement(lQuery2);
    ResultSet lRs = lStmt.executeQuery();
    while( lRs.next() )
    System.out.println(lRs.getString(1));
    users
    null
    please help!
    GreenX

    960714 wrote:
    Problem has been solved :)
    GreenxIt would be great if you could share the solution with us :)
    Thanks,
    Hussein

  • OOM on weblogic 10.3.2 JVM@check_alloc

    All
    On Linux 64 bit machine and weblogic 10.3.2 we are getting OOM very frequently.
    I have used MissionControl to see if there is any JavaHeap issue but I could not find any. I notice there is a constant increase in physical memory usage where as the Java Heap usage was increasing and decreasing at regular intervals(GC).
    Thanks in advance for your help.
    Below are the details for hardware and appserver startup params
    uname:
    Linux xxxxxx 2.6.18-164.6.1.el5 #1 SMP Tue Oct 27 11:28:30 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
    weblogicStartup:
    /apps/jrockit6-64/bin/java -Xms2048m -Xmx2048m -XXsetGC:genparcon -Xns:1536m -da -Dplatform.home=/apps/bea10.3.2/wlserver_10.3 -Dwls.home=/apps/bea10.3.2/wlserver_10.3/server -Dwli.home=/apps/bea10.3.2/wlserver_10.3/integration -Dweblogic.management.discover=false -Dweblogic.management.server=http://server-prod1:9400 -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole= -Dweblogic.ext.dirs=/apps/bea10.3.2/patch_wls1032/profiles/default/sysext_manifest_classpath -Dweblogic.Name=Server01 -Djava.security.policy=/apps/bea10.3.2/wlserver_10.3/server/lib/weblogic.policy weblogic.Server
    Exception from log file:
    java.lang.OutOfMemoryError: class allocation, 11055935600 loaded, 4140625920 footprint JVM@check_alloc (src/jvm/model/classload/classalloc.c:118). 2760 byt
    at sun.misc.Unsafe.defineClass(Native Method)
    at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)
    at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)
    at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)
    at sun.reflect.MethodAccessorGenerator.generateMethod(MethodAccessorGenerator.java:59)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:28)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at weblogic.spring.monitoring.utils.Delegator.invokeGetBoolean(Delegator.java:21)
    at weblogic.spring.monitoring.utils.AbstractBeanDefinitionDelegator.isPrototype(AbstractBeanDefinitionDelegator.java:59)
    at weblogic.spring.monitoring.actions.CreateBeanElapsedTimeActionState.setAbstractBeanDefinition(CreateBeanElapsedTimeActionState.java:19)
    at weblogic.spring.monitoring.actions.AbstractBeanFactoryCreateBeanAction.setArguments(AbstractBeanFactoryCreateBeanAction.java:36)
    at weblogic.spring.monitoring.actions.BaseElapsedTimeAction.preProcess(BaseElapsedTimeAction.java:58)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:379)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
    at com.app.distribution.util.ApplicationContextLoader.getBean(ApplicationContextLoader.java:23)
    at com.app.distribution.ejb.BatchDistributionMDB.onMessage(BatchDistributionMDB.java:49)
    at sun.reflect.GeneratedMethodAccessor93.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy90.onMessage(Unknown Source)
    at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
    at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4585)
    at weblogic.jms.client.JMSSession.execute(JMSSession.java:4271)
    at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3748)
    at weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
    at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5096)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

    Henrik
    Thanks very much for your response.
    I tried adding -XVerbose:class,gc and noticed that there are many classes created as follows.
    *[INFO ][class  ] created: #23722 com/beans/WSGResponse$JobInfo$JaxbAccessorF_subjobInfo*
    These classes are used to marshal and unmarshal xml payload from webservice request/response.
    There is a subJobInfo inner class in WSGResponse$JobInfo, but it looks like JAXB is creating subjobInfo(many similar classes are created) class on the fly. If this is a concern is there any way we can add few parameters to garbage collect these created classes.
    Below is the code snippet of the WSGResponse Class. I have removed getters and setters.
    package com.beans;
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlType;
    import com.beans.WSGRequest.OperationAttributes;
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "wsg-response", factoryClass = com.beans.ObjectFactory.class, factoryMethod = "createWSGResponse", propOrder = {
    "statusCode", "statusMessage", "operationAttributes", "jobInfo" })
    @XmlRootElement(name = "wsg-response")
    public class WSGResponse {
    @XmlElement(name = "status-code", required = false)
    protected String statusCode;
    @XmlElement(name = "status-message", required = false)
    protected String statusMessage;
    @XmlElement(name = "operation-attributes", required = false)
    protected OperationAttributes operationAttributes;
    @XmlElement(name = "job-info", required = false)
    protected WSGResponse.JobInfo jobInfo;
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "job-info", factoryClass = com.beans.ObjectFactory.class, factoryMethod = "createJobInfo", propOrder = {
    "jobClientId", "statusCode", "statusMessage", "subjobInfo" })
    public static class JobInfo {
    @XmlElement(name = "job-client-id", required = false)
    protected String jobClientId;
    @XmlElement(name = "status-code", required = false)
    protected String statusCode;
    @XmlElement(name = "status-message", required = false)
    protected String statusMessage;
    @XmlElement(name = "subjob-info", required = false)
    protected SubjobInfo subjobInfo;
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "subjob-info", factoryClass = com.beans.ObjectFactory.class, factoryMethod = "createSubjobInfo", propOrder = {
    "statusCode", "statusMessage", "jobIdentifier", "currentJobState", "destination" })
    public static class SubjobInfo {
    @XmlElement(name = "status-code", required = false)
    protected String statusCode;
    @XmlElement(name = "status-message", required = false)
    protected String statusMessage;
    @XmlElement(name = "job-identifier", required = false)
    protected String jobIdentifier;
    @XmlElement(name = "current-job-state", required = false)
    protected String currentJobState;
    @XmlElement(name = "destination", required = false)
    protected String destination;
    }

  • Unable to generate the XML file through SQL script. getting error PLS-00306

    I am fetching the data from cursor and generating the xml output I am getting the below error.
    When I have checked the cursor query it is fetching the data in to single column.
    Input truncated to 1 characters
    Enter value for 7: EXEC FND_CONC_STAT.COLLECT;
    DBMS_LOB.append (tmp_file, r.core_xml);
    ERROR at line 95:
    ORA-06550: line 95, column 7:
    PLS-00306: wrong number or types of arguments in call to 'APPEND'
    ORA-06550: line 95, column 7:
    PL/SQL: Statement ignored

    Hi Alex,
    thanks for the responce..
    i have fixed the issue
    i have used XMLAttributes to get the value
    SELECT XMLELEMENT (
    NAME "TranACK",
    XMLAttributes ('1' as "TranNum",
    (select distinct to_char(SYSDATE,'yyyy-mm-dd')
    from DUAL) as "PrcDate"),
    XMLFOREST (
    a.PAYMENT_ID AS "PmtID"),
    XMLFOREST (
    a.ACK_TRANSACTION_RECEIVER AS "Name1"),
    XMLFOREST (
    to_char(a.VALUE_DATE,'yyyy-mm-dd') as "ValueDate" ),
    XMLFOREST (
    a.PAYMENT_AMOUNT AS "CurAmt"),
    XMLFOREST (
    a.CURRENCY_CODE AS "CurCode")
    ).getclobval ()
    AS line_xml
    FROM XXWAP_PAYMENT_LINE_TBL a
    where a.PAYMENT_BATCH_ID=P_batch_id;

  • ORA 01792 maximum number of columns in a table or view is 1000

    Hello every1, I wish to register a large xmlschema doc, I am using the command
    begin
    dbms_xmlschema.registerschema(
    schemaurl=>'xxxx',
    schemadoc=>bfilename('XMLDIR','xxxxxx.xsd'),
    csid=>nls_charset_id('AL32UTF8'));
    end;
    But the schema file exists 1000 col and it gives me the error msg of
    ORA-01792: maximum number of columns in a table or view is 1000
    is there anyway to solve the problems without edit the original schema document?
    Thanks for your help

    First create this package
    create or replace package XDB_ANALYZE_XMLSCHEMA_10200
    authid CURRENT_USER
    as
      function analyzeStorageModel(P_COMPLEX_TYPE_NAME VARCHAR2) return XMLTYPE;
      function analyzeComplexType(COMPLEX_TYPE VARCHAR2) return XMLTYPE;
      procedure renameCollectionTable (XMLTABLE varchar2, XPATH varchar2, COLLECTION_TABLE_PREFIX varchar2);
      function printNestedTables(XML_TABLE varchar2) return XMLType;
      function getComplexTypeElementList(P_SQLTYPE VARCHAR2, P_SQLSCHEMA VARCHAR2) return XDB.XDB$XMLTYPE_REF_LIST_T;
      procedure scopeXMLReferences;
      procedure indexXMLReferences(INDEX_NAME VARCHAR2);
      function generateSchemaFromTable(P_TABLE_NAME varchar2, P_OWNER varchar2 default USER) return XMLTYPE;
      function showSQLTypes(schemaFolder varchar2) return XMLType;
      function generateCreateTableStatement(XML_TABLE_NAME varchar2, NEW_TABLE_NAME varchar2) return CLOB;
    end XDB_ANALYZE_XMLSCHEMA_10200;
    show errors
    create or replace package body XDB_ANALYZE_XMLSCHEMA_10200
    as
    G_DEPTH_COUNT NUMBER(2) := 0;
    TYPE BASETYPE_T is RECORD  
      SUBTYPE               varchar2(128),
      SUBTYPE_OWNER         varchar2(32),
      BASETYPE              varchar2(128),
      BASETYPE_OWNER        varchar2(32)
    TYPE BASETYPE_LIST_T IS TABLE OF BASETYPE_T;
    BASETYPE_LIST            BASETYPE_LIST_T := BASETYPE_LIST_T();
    function findStorageModel(P_TYPE_NAME VARCHAR2, P_TYPE_OWNER VARCHAR2,  P_INCLUDE_SUBTYPES VARCHAR2 DEFAULT 'YES') return XMLType;
    function getLocalAttributes(P_TYPE_NAME varchar2, P_TYPE_OWNER VARCHAR2) return XMLType;
    function makeElement(P_NAME varchar2)
    return xmltype
    as
      V_NAME varchar2(4000) := P_NAME;
    begin
      -- -- dbms_output.put_line('Processing : ' || P_NAME);
      if (P_NAME LIKE '%$') then
        V_NAME := SUBSTR(V_NAME,1,LENGTH(V_NAME) - 1);
      end if;
      if (P_NAME LIKE '%$%') then
        V_NAME := REPLACE(V_NAME,'$','_0x22_');
      end if;
      return XMLTYPE( '<' || V_NAME || '/>');
    end;
    function getPathToRoot(SUBTYPE VARCHAR2, SUBTYPE_OWNER VARCHAR2)
    return varchar2
    as
      TYPE_HIERARCHY varchar2(4000);
    begin
       SELECT sys_connect_by_path( OWNER || '.' || TYPE_NAME , '/')
         INTO TYPE_HIERARCHY
         FROM ALL_TYPES
        WHERE TYPE_NAME = SUBTYPE
          AND OWNER = SUBTYPE_OWNER
              CONNECT BY SUPERTYPE_NAME = PRIOR TYPE_NAME
                     AND SUPERTYPE_OWNER = PRIOR OWNER
              START WITH SUPERTYPE_NAME IS NULL
                     AND SUPERTYPE_OWNER IS NULL;
       return TYPE_HIERARCHY;
    end;
    function expandSQLType(ATTR_NAME VARCHAR2, SUBTYPE VARCHAR2, SUBTYPE_OWNER VARCHAR2)
    return XMLType
    as
      STORAGE_MODEL       XMLTYPE;
      ATTRIBUTES          XMLTYPE;
      EXTENDED_TYPE       XMLTYPE;
      ATTR_COUNT          NUMBER := 0;
      CURSOR FIND_EXTENDED_TYPES
      is
      select TYPE_NAME, OWNER
        from ALL_TYPES
       where SUPERTYPE_NAME  = SUBTYPE
         and SUPERTYPE_OWNER = SUBTYPE_OWNER;
    begin
      -- dbms_output.put_line('Processing SQLType  : "' || SUBTYPE_OWNER || '.' || SUBTYPE || '".' );
      STORAGE_MODEL := makeElement(ATTR_NAME);
      select insertChildXML(STORAGE_MODEL,'/' || STORAGE_MODEL.getRootElement(),'@type',SUBTYPE)
        into STORAGE_MODEL
        from dual;
      select insertChildXML(STORAGE_MODEL,'/' || STORAGE_MODEL.getRootElement(),'@typeOwner',SUBTYPE_OWNER)
        into STORAGE_MODEL
        from dual;
      ATTRIBUTES := getLocalAttributes(SUBTYPE, SUBTYPE_OWNER);         
      ATTR_COUNT := ATTR_COUNT + ATTRIBUTES.extract('/' || ATTRIBUTES.getRootElement() || '/@columns').getNumberVal();
      select appendChildXML(STORAGE_MODEL,'/' || STORAGE_MODEL.getRootElement(),ATTRIBUTES)
        into STORAGE_MODEL        
        from DUAL;
      for t in FIND_EXTENDED_TYPES loop
         EXTENDED_TYPE := expandSQLType('ExtendedType',T.TYPE_NAME,T.OWNER);
         ATTR_COUNT := ATTR_COUNT + EXTENDED_TYPE.extract('/' || EXTENDED_TYPE.getRootElement() || '/@columns').getNumberVal();
         select appendChildXML(STORAGE_MODEL,'/' || STORAGE_MODEL.getRootElement(),EXTENDED_TYPE)
           into STORAGE_MODEL
           from DUAL;   
      end loop;
      select insertChildXML(STORAGE_MODEL,'/' || STORAGE_MODEL.getRootElement(),'@columns',ATTR_COUNT)
        into STORAGE_MODEL
        from dual;
      return STORAGE_MODEL;
    end;
    function getLocalAttributes(P_TYPE_NAME varchar2, P_TYPE_OWNER VARCHAR2)
    return XMLType
    as
      V_ATTRIBUTE_COUNT     NUMBER := 0;
      V_TOTAL_ATTRIBUTES    NUMBER := 0;
      V_TEMP_RESULT         NUMBER;
      V_COLLECTION_TYPE     varchar2(32);
      V_COLLECTION_OWNER    varchar2(32);
      CURSOR FIND_CHILD_ATTRS
      is
      select ATTR_NAME, ATTR_TYPE_OWNER, ATTR_TYPE_NAME, INHERITED
        from ALL_TYPE_ATTRS
       where TYPE_NAME = P_TYPE_NAME
         and OWNER = P_TYPE_OWNER
         and INHERITED = 'NO'
       order by ATTR_NO;       
      V_ATTR                    DBMS_XMLDOM.DOMATTR;
      V_ATTRIBUTE_LIST      XMLTYPE;
      V_ATTRIBUTE_LIST_DOCUMENT DBMS_XMLDOM.DOMDOCUMENT;
      V_ATTRIBUTE_LIST_ROOT     DBMS_XMLDOM.DOMELEMENT;
      V_ATTRIBUTE           XMLTYPE;
      V_ATTRIBUTE_DOCUMENT                DBMS_XMLDOM.DOMDOCUMENT;
      V_ATTRIBUTE_ROOT                    DBMS_XMLDOM.DOMELEMENT;
      V_TYPE_DEFINITION     XMLTYPE;
      V_TYPE_DEFINITION_DOCUMENT  DBMS_XMLDOM.DOMDOCUMENT;
      V_TYPE_DEFINITION_ROOT      DBMS_XMLDOM.DOMELEMENT;
    begin    
      V_ATTRIBUTE_LIST          := makeElement('Attributes');
      V_ATTRIBUTE_LIST_DOCUMENT := DBMS_XMLDOM.NEWDOMDOCUMENT(V_ATTRIBUTE_LIST);
      V_ATTRIBUTE_LIST_ROOT     := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_ATTRIBUTE_LIST_DOCUMENT);
      for ATTR in FIND_CHILD_ATTRS loop
        -- Finding Element / Attribute Name could be tricky. Use SQLName
        V_ATTRIBUTE          := makeElement(ATTR.ATTR_NAME);
        V_ATTRIBUTE_DOCUMENT := DBMS_XMLDOM.NEWDOMDOCUMENT(V_ATTRIBUTE);
        V_ATTRIBUTE_ROOT     := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_ATTRIBUTE_DOCUMENT);
        begin
          -- Check for Attributes based on collection types, With Nested Table storage each Collection will cost 2 columns.
          select ELEM_TYPE_NAME, ELEM_TYPE_OWNER
            into V_COLLECTION_TYPE, V_COLLECTION_OWNER
            from ALL_COLL_TYPES
           where TYPE_NAME = ATTR.ATTR_TYPE_NAME
             and OWNER = ATTR.ATTR_TYPE_OWNER;
          -- -- dbms_output.put_line('Adding "' || ATTR.ATTR_NAME || '". Collection of "' || ATTR.ATTR_TYPE_OWNER || '"."' || ATTR.ATTR_TYPE_NAME || '".');
          -- Attribute is a Collection Type.
          -- Collection will be managed as a NESTED TABLE
          -- Each Collection cost 2 columns.
          -- May want to count the number of columns in the NESTED_TABLE at a later date.
          V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'SQLCollType');
                         DBMS_XMLDOM.SETVALUE(V_ATTR,ATTR.ATTR_TYPE_NAME);
          V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
          V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'SQLCollTypeOwner');
                         DBMS_XMLDOM.SETVALUE(V_ATTR,ATTR.ATTR_TYPE_OWNER);
          V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
          V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'SQLType');
                         DBMS_XMLDOM.SETVALUE(V_ATTR,V_COLLECTION_TYPE);
          V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
          V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'SQLTypeOwner');
                         DBMS_XMLDOM.SETVALUE(V_ATTR,V_COLLECTION_OWNER);
          V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
          V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'columns');
                         DBMS_XMLDOM.SETVALUE(V_ATTR,2);
          V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
        exception
          when no_data_found then
            -- Attribute is not a collection type.
            begin
              -- Check for Attributes based on non-scalar types.
              select 1
                into V_TEMP_RESULT
                from ALL_TYPES
               where TYPE_NAME = ATTR.ATTR_TYPE_NAME
                 and OWNER = ATTR.ATTR_TYPE_OWNER;
              -- Attribute is based on a non-scalar type. Find the Storage Model for this type.
              V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'SQLType');
                             DBMS_XMLDOM.SETVALUE(V_ATTR,ATTR.ATTR_TYPE_NAME);
              V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
              V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'SQLTypeOwner');
                             DBMS_XMLDOM.SETVALUE(V_ATTR,ATTR.ATTR_TYPE_OWNER);
              V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
              V_TYPE_DEFINITION            := findStorageModel(ATTR.ATTR_TYPE_NAME, ATTR.ATTR_TYPE_OWNER, 'YES');   
              V_TYPE_DEFINITION_DOCUMENT   := DBMS_XMLDOM.NEWDOMDOCUMENT(V_TYPE_DEFINITION);
              V_TYPE_DEFINITION_ROOT       := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_TYPE_DEFINITION_DOCUMENT);
              V_ATTRIBUTE_COUNT            := DBMS_XMLDOM.GETATTRIBUTE(V_TYPE_DEFINITION_ROOT,'columns');
              V_TYPE_DEFINITION_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.IMPORTNODE(V_ATTRIBUTE_DOCUMENT,DBMS_XMLDOM.MAKENODE(V_TYPE_DEFINITION_ROOT),TRUE));
              V_TYPE_DEFINITION_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(V_ATTRIBUTE_ROOT),DBMS_XMLDOM.MAKENODE(V_TYPE_DEFINITION_ROOT)));
              DBMS_XMLDOM.FREEDOCUMENT(V_TYPE_DEFINITION_DOCUMENT);
              if (ATTR.ATTR_TYPE_NAME = 'XDB$ENUM_T' and ATTR.ATTR_TYPE_OWNER = 'XDB') then
                -- The cost of a XDB$ENUM_T is 2 columns
                V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'columns');
                               DBMS_XMLDOM.SETVALUE(V_ATTR,2);
                V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
              else
                -- The cost of a non scalar Type is the number of attributes plus one for Type and one for the TYPEID.
                V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'columns');
                               DBMS_XMLDOM.SETVALUE(V_ATTR,V_ATTRIBUTE_COUNT + 2);
                V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
              end if;
            exception
              when no_data_found then
                 -- Attribute is based on a scalar type
                 V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'SQLType');
                                DBMS_XMLDOM.SETVALUE(V_ATTR,ATTR.ATTR_TYPE_NAME);
                 V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
                 V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_DOCUMENT,'columns');
                                DBMS_XMLDOM.SETVALUE(V_ATTR,1);
                 V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_ROOT,V_ATTR);
            end;
        end;
        V_TOTAL_ATTRIBUTES     := V_TOTAL_ATTRIBUTES + DBMS_XMLDOM.GETATTRIBUTE(V_ATTRIBUTE_ROOT,'columns');
        V_ATTRIBUTE_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.IMPORTNODE(V_ATTRIBUTE_LIST_DOCUMENT,DBMS_XMLDOM.MAKENODE(V_ATTRIBUTE_ROOT),TRUE));
        V_ATTRIBUTE_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(V_ATTRIBUTE_LIST_ROOT),DBMS_XMLDOM.MAKENODE(V_ATTRIBUTE_ROOT)));
        DBMS_XMLDOM.FREEDOCUMENT(V_ATTRIBUTE_DOCUMENT);
        if (V_TOTAL_ATTRIBUTES > 25000) then
          exit;
        end if;
      end loop;
      V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_ATTRIBUTE_LIST_DOCUMENT,'columns');
                     DBMS_XMLDOM.SETVALUE(V_ATTR,V_TOTAL_ATTRIBUTES);
      V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ATTRIBUTE_LIST_ROOT,V_ATTR);
      return V_ATTRIBUTE_LIST;
    end;
    function getSubTypes(P_TYPE_NAME VARCHAR2, P_TYPE_OWNER VARCHAR2)
    return XMLType
    as
      CURSOR FIND_SUBTYPES
      is
      select TYPE_NAME, OWNER
        from ALL_TYPES
       where SUPERTYPE_NAME  = P_TYPE_NAME
         and SUPERTYPE_OWNER = P_TYPE_OWNER; 
      CURSOR FIND_SUBTYPE_HEIRARCHY
      is
      select LEVEL, TYPE_NAME, OWNER
        from ALL_TYPES
       where TYPE_NAME <> P_TYPE_NAME
         and OWNER <> P_TYPE_OWNER
             connect by SUPERTYPE_NAME = PRIOR TYPE_NAME
                    and SUPERTYPE_OWNER = PRIOR OWNER
             start with TYPE_NAME = P_TYPE_NAME
                    and OWNER = P_TYPE_OWNER;
      V_SUBTYPE_LIST                 XMLType;
      V_SUBTYPE_LIST_DOCUMENT        DBMS_XMLDOM.DOMDOCUMENT;
      V_SUBTYPE_LIST_ROOT            DBMS_XMLDOM.DOMELEMENT;
      V_TYPE_DEFINITION              XMLType;
      V_TYPE_DEFINITION_DOCUMENT     DBMS_XMLDOM.DOMDOCUMENT;
      V_TYPE_DEFINITION_ROOT         DBMS_XMLDOM.DOMELEMENT;
      V_SUBTYPE_DEFINITIONS          XMLType;
      V_SUBTYPE_DEFINITIONS_DOCUMENT DBMS_XMLDOM.DOMDOCUMENT;
      V_SUBTYPE_DEFINITIONS_ROOT     DBMS_XMLDOM.DOMELEMENT;
      V_ATTRIBUTE_LIST               XMLType;
      V_ATTRIBUTE_LIST_DOCUMENT      DBMS_XMLDOM.DOMDOCUMENT;
      V_ATTRIBUTE_LIST_ROOT          DBMS_XMLDOM.DOMELEMENT;
      V_SUBTYPES_EXIST               BOOLEAN := FALSE;
      V_TOTAL_columns                number;
      V_ATTRIBUTE_COUNT              number;
      V_ATTR                         DBMS_XMLDOM.DOMATTR;
      V_COMPLEX_TYPE                 VARCHAR2(256);
    begin
      V_SUBTYPE_LIST          := makeElement('SubTypeDefinitions');
      V_SUBTYPE_LIST_DOCUMENT := DBMS_XMLDOM.NEWDOMDOCUMENT(V_SUBTYPE_LIST);
      V_SUBTYPE_LIST_ROOT     := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_SUBTYPE_LIST_DOCUMENT);
      V_TOTAL_columns := 0;
      for t in FIND_SUBTYPES() loop
        V_SUBTYPES_EXIST  := TRUE;
        V_TYPE_DEFINITION            := makeElement(t.TYPE_NAME);
        V_TYPE_DEFINITION_DOCUMENT   := DBMS_XMLDOM.NEWDOMDOCUMENT(V_TYPE_DEFINITION);
        V_TYPE_DEFINITION_ROOT       := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_TYPE_DEFINITION_DOCUMENT);
        V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_TYPE_DEFINITION_DOCUMENT,'SQLTypeOwner');
                       DBMS_XMLDOM.SETVALUE(V_ATTR,t.OWNER);
        V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_TYPE_DEFINITION_ROOT,V_ATTR);
        begin
          select x.XMLDATA.NAME
            into V_COMPLEX_TYPE
            from XDB.XDB$COMPLEX_TYPE x
           where x.XMLDATA.SQLTYPE = t.TYPE_NAME
             and x.XMLDATA.SQLSCHEMA = t.OWNER;
          V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_TYPE_DEFINITION_DOCUMENT,'type');
                         DBMS_XMLDOM.SETVALUE(V_ATTR,V_COMPLEX_TYPE);
          V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_TYPE_DEFINITION_ROOT,V_ATTR);
          -- Consider adding Schema URL Attribute
        exception
          when no_data_found then
            null;
          when others then
            raise;
        end;
        V_ATTRIBUTE_LIST            := getLocalAttributes(t.TYPE_NAME, t.OWNER);  
        V_ATTRIBUTE_LIST_DOCUMENT   := DBMS_XMLDOM.NEWDOMDOCUMENT(V_ATTRIBUTE_LIST);
        V_ATTRIBUTE_LIST_ROOT       := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_ATTRIBUTE_LIST_DOCUMENT);
        V_ATTRIBUTE_COUNT           := DBMS_XMLDOM.GETATTRIBUTE(V_ATTRIBUTE_LIST_ROOT,'columns');
        V_ATTRIBUTE_LIST_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.IMPORTNODE(V_TYPE_DEFINITION_DOCUMENT,DBMS_XMLDOM.MAKENODE(V_ATTRIBUTE_LIST_ROOT),TRUE));
        V_ATTRIBUTE_LIST_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(V_TYPE_DEFINITION_ROOT),DBMS_XMLDOM.MAKENODE(V_ATTRIBUTE_LIST_ROOT)));
        DBMS_XMLDOM.FREEDOCUMENT(V_ATTRIBUTE_LIST_DOCUMENT);
        V_SUBTYPE_DEFINITIONS       := getSubTypes(t.TYPE_NAME,t.OWNER);
        if (V_SUBTYPE_DEFINITIONS is not NULL) then
          V_SUBTYPE_DEFINITIONS_DOCUMENT   := DBMS_XMLDOM.NEWDOMDOCUMENT(V_SUBTYPE_DEFINITIONS);
          V_SUBTYPE_DEFINITIONS_ROOT       := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_SUBTYPE_DEFINITIONS_DOCUMENT);
          V_ATTRIBUTE_COUNT                := V_ATTRIBUTE_COUNT + DBMS_XMLDOM.GETATTRIBUTE(V_SUBTYPE_DEFINITIONS_ROOT,'columns');
          V_SUBTYPE_DEFINITIONS_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.IMPORTNODE(V_TYPE_DEFINITION_DOCUMENT,DBMS_XMLDOM.MAKENODE(V_SUBTYPE_DEFINITIONS_ROOT),TRUE));
          V_SUBTYPE_DEFINITIONS_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(V_TYPE_DEFINITION_ROOT),DBMS_XMLDOM.MAKENODE(V_SUBTYPE_DEFINITIONS_ROOT)));
        end if;
        V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_TYPE_DEFINITION_DOCUMENT,'columns');
                       DBMS_XMLDOM.SETVALUE(V_ATTR,V_ATTRIBUTE_COUNT);
        V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_TYPE_DEFINITION_ROOT,V_ATTR);
        V_TYPE_DEFINITION_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.IMPORTNODE(V_SUBTYPE_LIST_DOCUMENT,DBMS_XMLDOM.MAKENODE(V_TYPE_DEFINITION_ROOT),TRUE));
        V_TYPE_DEFINITION_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(V_SUBTYPE_LIST_ROOT),DBMS_XMLDOM.MAKENODE(V_TYPE_DEFINITION_ROOT)));
        V_TOTAL_columns := V_TOTAL_columns + V_ATTRIBUTE_COUNT;
      end loop;
      if (V_SUBTYPES_EXIST) then
        V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_SUBTYPE_LIST_DOCUMENT,'columns');
                       DBMS_XMLDOM.SETVALUE(V_ATTR,V_TOTAL_columns);
        V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_SUBTYPE_LIST_ROOT,V_ATTR);
        return V_SUBTYPE_LIST;
      else
        return NULL;
      end if;
    end;
    function findSuperTypeModel(P_TYPE_NAME VARCHAR2, P_TYPE_OWNER VARCHAR2)
    return XMLType
    as
    begin
      -- dbms_output.put_line('Processing Super Type : "' || P_TYPE_OWNER || '"."' || P_TYPE_NAME || '"');
      return findStorageModel(P_TYPE_NAME, P_TYPE_OWNER,'NO');
    end;
    function getStorageModel(P_TYPE_NAME VARCHAR2, P_TYPE_OWNER VARCHAR2, P_INCLUDE_SUBTYPES VARCHAR2 DEFAULT 'YES')
    return XMLType
    as
      V_TYPE_DEFINITION      XMLTYPE;
      V_ATTRIBUTE_COUNT      NUMBER := 0;
      SUBTYPE_STORAGE_MODEL  XMLTYPE;
      V_SUPERTYPE_DEFINITION XMLTYPE;
      V_SUPERTYPE_DOCUMENT   DBMS_XMLDOM.DOMDOCUMENT;
      V_SUPERTYPE_ROOT       DBMS_XMLDOM.DOMELEMENT;
      V_SUBTYPE_DEFINITION XMLTYPE;
      V_SUBTYPE_DOCUMENT   DBMS_XMLDOM.DOMDOCUMENT;
      V_SUBTYPE_ROOT       DBMS_XMLDOM.DOMELEMENT;
      V_ATTRIBUTE_LIST          XMLTYPE;
      V_ATTRIBUTE_LIST_DOCUMENT DBMS_XMLDOM.DOMDOCUMENT;
      V_ATTRIBUTE_LIST_ROOT     DBMS_XMLDOM.DOMELEMENT;
      cursor FIND_SUPERTYPE_HEIRARCHY
      is
      select TYPE_NAME, OWNER
        from ALL_TYPES
       where TYPE_NAME <> P_TYPE_NAME
         and OWNER <> P_TYPE_OWNER
             connect by TYPE_NAME = PRIOR SUPERTYPE_NAME
                    and OWNER = PRIOR SUPERTYPE_OWNER
             start with TYPE_NAME = P_TYPE_NAME
                    and OWNER = P_TYPE_OWNER
       order by LEVEL;
      V_COMPLEX_TYPE        varchar2(256);
      V_SUPERTYPE_NAME      varchar2(256);
      v_SUPERTYPE_OWNER     varchar2(256);
      V_DOCUMENT            DBMS_XMLDOM.DOMDOCUMENT;
      V_ROOT                DBMS_XMLDOM.DOMELEMENT;
      V_ATTR                DBMS_XMLDOM.DOMATTR;
    begin
      -- dbms_output.put_line('Generating Storage Model for : "' || P_TYPE_OWNER || '"."' || P_TYPE_NAME || '"');
      V_TYPE_DEFINITION := makeElement(P_TYPE_NAME);
      V_DOCUMENT  := DBMS_XMLDOM.NEWDOMDOCUMENT(V_TYPE_DEFINITION);
      V_ROOT      := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_DOCUMENT);
      V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_DOCUMENT,'SQLTypeOwner');
                     DBMS_XMLDOM.SETVALUE(V_ATTR,P_TYPE_OWNER);
      V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ROOT,V_ATTR);
      begin
        select x.XMLDATA.NAME
          into V_COMPLEX_TYPE
          from XDB.XDB$COMPLEX_TYPE x
         where x.XMLDATA.SQLTYPE = P_TYPE_NAME
           and x.XMLDATA.SQLSCHEMA = P_TYPE_OWNER;
        V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_DOCUMENT,'type');
                       DBMS_XMLDOM.SETVALUE(V_ATTR,V_COMPLEX_TYPE);
        V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ROOT,V_ATTR);
        -- Consider adding Schema URL Attribute
      exception
        when no_data_found then
          null;
        when others then
          raise;
      end;
      select SUPERTYPE_NAME, SUPERTYPE_OWNER
        into V_SUPERTYPE_NAME, V_SUPERTYPE_OWNER
        from ALL_TYPES
       where TYPE_NAME = P_TYPE_NAME
         and OWNER = P_TYPE_OWNER;
      -- Process SuperType. 
      if (V_SUPERTYPE_NAME is not null) then
        V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_DOCUMENT,'SQLParentType');
                       DBMS_XMLDOM.SETVALUE(V_ATTR,V_SUPERTYPE_NAME);
        V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ROOT,V_ATTR);
        V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_DOCUMENT,'SQLParentTypeOwner');
                       DBMS_XMLDOM.SETVALUE(V_ATTR,V_SUPERTYPE_OWNER);
        V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ROOT,V_ATTR);
        -- Find the Definition for the super type. Do not include the definition of it's subtypes.
        V_SUPERTYPE_DEFINITION := findSuperTypeModel(V_SUPERTYPE_NAME, V_SUPERTYPE_OWNER);
        -- -- dbms_output.put_line(dbms_lob.substr(V_SUPERTYPE_DEFINITION.getClobVal(),1000,1));
        V_SUPERTYPE_DOCUMENT   := DBMS_XMLDOM.NEWDOMDOCUMENT(V_SUPERTYPE_DEFINITION);
        V_SUPERTYPE_ROOT       := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_SUPERTYPE_DOCUMENT);
        V_ATTRIBUTE_COUNT      := V_ATTRIBUTE_COUNT + DBMS_XMLDOM.GETATTRIBUTE(V_SUPERTYPE_ROOT,'columns');
        V_SUPERTYPE_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.IMPORTNODE(V_DOCUMENT,DBMS_XMLDOM.MAKENODE(V_SUPERTYPE_ROOT),TRUE));
        V_SUPERTYPE_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(V_ROOT),DBMS_XMLDOM.MAKENODE(V_SUPERTYPE_ROOT)));
        DBMS_XMLDOM.FREEDOCUMENT(V_SUPERTYPE_DOCUMENT);
      end if;
      -- Process Attributes defined directly by the Type.
      V_ATTRIBUTE_LIST            := getLocalAttributes(P_TYPE_NAME, P_TYPE_OWNER);  
      V_ATTRIBUTE_LIST_DOCUMENT   := DBMS_XMLDOM.NEWDOMDOCUMENT(V_ATTRIBUTE_LIST);
      V_ATTRIBUTE_LIST_ROOT       := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_ATTRIBUTE_LIST_DOCUMENT);
      V_ATTRIBUTE_COUNT           := V_ATTRIBUTE_COUNT + DBMS_XMLDOM.GETATTRIBUTE(V_ATTRIBUTE_LIST_ROOT,'columns');
      V_ATTRIBUTE_LIST_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.IMPORTNODE(V_DOCUMENT,DBMS_XMLDOM.MAKENODE(V_ATTRIBUTE_LIST_ROOT),TRUE));
      V_ATTRIBUTE_LIST_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(V_ROOT),DBMS_XMLDOM.MAKENODE(V_ATTRIBUTE_LIST_ROOT)));
      DBMS_XMLDOM.FREEDOCUMENT(V_ATTRIBUTE_LIST_DOCUMENT);
      if (P_INCLUDE_SUBTYPES = 'YES') then
        -- Process any Sub-Types...
        V_SUBTYPE_DEFINITION := getSubTypes(P_TYPE_NAME, P_TYPE_OWNER);
        if (V_SUBTYPE_DEFINITION is not null) then
          V_SUBTYPE_DOCUMENT   := DBMS_XMLDOM.NEWDOMDOCUMENT(V_SUBTYPE_DEFINITION);
          V_SUBTYPE_ROOT       := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_SUBTYPE_DOCUMENT);
          V_ATTRIBUTE_COUNT    := V_ATTRIBUTE_COUNT + DBMS_XMLDOM.GETATTRIBUTE(V_SUBTYPE_ROOT,'columns');
          V_SUBTYPE_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.IMPORTNODE(V_DOCUMENT,DBMS_XMLDOM.MAKENODE(V_SUBTYPE_ROOT),TRUE));
          V_SUBTYPE_ROOT       := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(V_ROOT),DBMS_XMLDOM.MAKENODE(V_SUBTYPE_ROOT)));   
          DBMS_XMLDOM.FREEDOCUMENT(V_SUBTYPE_DOCUMENT);
        end if;
      end if;
      V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_DOCUMENT,'columns');
                     DBMS_XMLDOM.SETVALUE(V_ATTR,V_ATTRIBUTE_COUNT);
      V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ROOT,V_ATTR);
      -- Cache the type definition.
      -- dbms_output.put_line('Cached Storage Model for "' || P_TYPE_OWNER || '.' || P_TYPE_NAME || '".');
      insert into XDBPM.XDBPM_STORAGE_MODEL_CACHE (TYPE_NAME, TYPE_OWNER, EXTENDED_DEFINITION, STORAGE_MODEL) VALUES (P_TYPE_NAME, P_TYPE_OWNER, P_INCLUDE_SUBTYPES, V_TYPE_DEFINITION);
      return V_TYPE_DEFINITION;
    end;
    function findStorageModel(P_TYPE_NAME VARCHAR2, P_TYPE_OWNER VARCHAR2, P_INCLUDE_SUBTYPES VARCHAR2 DEFAULT 'YES')
    -- Find the Storage Model for the Base Type.
    -- If the type is derived from another type we need the storage model of the Base Type
    -- As storage models are calculated they are cached in the global temporary table XDBPM_STORAGE_MODEL_CACHE. This makes
    -- the process much more efficient. A global temporary table is used to minimize memory usage.
    return XMLType
    as
      V_STORAGE_MODEL          XMLType;
      V_STORAGE_MODEL_DOCUMENT DBMS_XMLDOM.DOMDOCUMENT;
      V_STORAGE_MODEL_ROOT     DBMS_XMLDOM.DOMELEMENT;
      V_ATTRIBUTE_COUNT        VARCHAR2(10);
    begin
      dbms_output.put_line('findStorageModel(' || G_DEPTH_COUNT || ') : Processing "' || P_TYPE_OWNER || '"."' || P_TYPE_NAME || '".' );
      begin
        SELECT STORAGE_MODEL
          into V_STORAGE_MODEL
          from XDBPM.XDBPM_STORAGE_MODEL_CACHE
         where TYPE_NAME = P_TYPE_NAME
           and TYPE_OWNER = P_TYPE_OWNER
           and EXTENDED_DEFINITION = P_INCLUDE_SUBTYPES;
         -- dbms_output.put_line('Resolved Storage Model from cache.');
      exception
        when no_data_found then
          G_DEPTH_COUNT := G_DEPTH_COUNT + 1;
          V_STORAGE_MODEL := getStorageModel(P_TYPE_NAME,P_TYPE_OWNER, P_INCLUDE_SUBTYPES);
          G_DEPTH_COUNT := G_DEPTH_COUNT - 1; 
        when others then
          raise;
      end;
      V_STORAGE_MODEL_DOCUMENT := DBMS_XMLDOM.NEWDOMDOCUMENT(V_STORAGE_MODEL);
      V_STORAGE_MODEL_ROOT     := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_STORAGE_MODEL_DOCUMENT);
      V_ATTRIBUTE_COUNT          := DBMS_XMLDOM.GETATTRIBUTE(V_STORAGE_MODEL_ROOT,'columns');
      dbms_output.put_line('findStorageModel : Attribute Count for "' || P_TYPE_OWNER || '"."' || P_TYPE_NAME || '" = ' || V_ATTRIBUTE_COUNT || '.' );
      return V_STORAGE_MODEL;
    end;
    function analyzeStorageModel(P_COMPLEX_TYPE_NAME VARCHAR2, P_TYPE_NAME VARCHAR2, P_TYPE_OWNER VARCHAR2)
    -- Generate a map showing the number of columns required to persist an instance of the SQL type.
    return XMLType
    as
      V_STORAGE_MODEL       XMLTYPE;
      V_COUNT               NUMBER := 0;
      V_DOCUMENT            DBMS_XMLDOM.DOMDOCUMENT;
      V_ROOT                DBMS_XMLDOM.DOMELEMENT;
      V_ATTR                DBMS_XMLDOM.DOMATTR;
      V_MODEL               DBMS_XMLDOM.DOMELEMENT;
      V_TYPE_DEFINITION     DBMS_XMLDOM.DOMELEMENT;
    begin
      V_STORAGE_MODEL := makeElement(P_COMPLEX_TYPE_NAME);
      V_DOCUMENT  := DBMS_XMLDOM.NEWDOMDOCUMENT(V_STORAGE_MODEL);
      V_ROOT      := DBMS_XMLDOM.GETDOCUMENTELEMENT(V_DOCUMENT);
      V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_DOCUMENT,'SQLType');
                     DBMS_XMLDOM.SETVALUE(V_ATTR,P_TYPE_NAME);
      V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ROOT,V_ATTR);
      V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_DOCUMENT,'SQLTypeOwner');
                     DBMS_XMLDOM.SETVALUE(V_ATTR,P_TYPE_OWNER);
      V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ROOT,V_ATTR);
      V_TYPE_DEFINITION   := DBMS_XMLDOM.GETDOCUMENTELEMENT(DBMS_XMLDOM.NEWDOMDOCUMENT(findStorageModel(P_TYPE_NAME, P_TYPE_OWNER, 'YES')));
      V_TYPE_DEFINITION   := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.IMPORTNODE(V_DOCUMENT,DBMS_XMLDOM.MAKENODE(V_TYPE_DEFINITION),TRUE));
      V_TYPE_DEFINITION   := DBMS_XMLDOM.MAKEELEMENT(DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(V_ROOT),DBMS_XMLDOM.MAKENODE(V_TYPE_DEFINITION)));
      V_ATTR      := DBMS_XMLDOM.CREATEATTRIBUTE(V_DOCUMENT,'columns');
                     DBMS_XMLDOM.SETVALUE(V_ATTR,DBMS_XMLDOM.GETATTRIBUTE(V_TYPE_DEFINITION,'columns'));
      V_ATTR      := DBMS_XMLDOM.SETATTRIBUTENODE(V_ROOT,V_ATTR);
      return  V_STORAGE_MODEL;
    end;
    function analyzeStorageModel(P_COMPLEX_TYPE_NAME VARCHAR2)
    return XMLTYPE
    -- Generate a map showing the number of columns required to persist an instance of the complex type.
    as
      pragma autonomous_transaction;
      V_SQLTYPE           VARCHAR2(128);
      V_SQLSCHEMA         VARCHAR2(32);
      V_RESULT            XMLType;
    begin
    G_DEPTH_COUNT := 0;
    select ct.XMLDATA.SQLTYPE, ct.XMLDATA.SQLSCHEMA
        into V_SQLTYPE, V_SQLSCHEMA
        from XDB.XDB$COMPLEX_TYPE ct, XDB.XDB$SCHEMA s
       where ct.XMLDATA.NAME = P_COMPLEX_TYPE_NAME
         and ref(s) = ct.XMLDATA.PARENT_SCHEMA
         and s.XMLDATA.SCHEMA_OWNER = USER;
      delete from XDBPM.XDBPM_STORAGE_MODEL_CACHE;
      -- delete from XDBPM.XDBPM_STORAGE_MODEL;
      V_RESULT := analyzeStorageModel(P_COMPLEX_TYPE_NAME,V_SQLTYPE,V_SQLSCHEMA);
      COMMIT;
      return V_RESULT;
    exception
      when no_data_found then
        -- dbms_output.put_line('Unable to find SQLType mapping for complexType : "' || USER || '"."' || P_COMPLEX_TYPE_NAME || '".' );
        return null;
      when others then
        raise;
    end;
    function analyzeSQLType(ATTR_NAME VARCHAR2, TARGET_TYPE_NAME VARCHAR2, TARGET_TYPE_OWNER VARCHAR2)
    return XMLType
    as
       ROOT_NODE_NAME   VARCHAR2(128);
       ATTR_DETAIL      XMLTYPE;
       XPATH_EXPRESSION VARCHAR2(129);
       CURSOR FIND_CHILD_ATTRS is
         select ATTR_NAME, ATTR_TYPE_OWNER, ATTR_TYPE_NAME, INHERITED
           from ALL_TYPE_ATTRS
          where OWNER = TARGET_TYPE_OWNER
            and TYPE_NAME = TARGET_TYPE_NAME
          order by ATTR_NO;       
       CHILD_ATTR  XMLTYPE;
       ATTR_COUNT NUMBER := 0;
       TEMP number;
       COLLECTION_TYPE_NAME  varchar2(256);
       COLLECTION_TYPE_OWNER varchar2(256);
    begin
      -- -- dbms_output.put_line('Processing Attribute ' || ATTR_NAME || ' of ' || TARGET_TYPE_OWNER || '.' || TARGET_TYPE_NAME );
      ATTR_DETAIL := makeElement(ATTR_NAME);
      XPATH_EXPRESSION := '/' || ATTR_DETAIL.GETROOTELEMENT();
      for ATTR in FIND_CHILD_ATTRS loop
        begin
          select ELEM_TYPE_NAME, ELEM_TYPE_OWNER
            into COLLECTION_TYPE_NAME, COLLECTION_TYPE_OWNER
            from ALL_COLL_TYPES
           where TYPE_NAME = ATTR.ATTR_TYPE_NAME
             and OWNER = ATTR.ATTR_TYPE_OWNER;
          CHILD_ATTR := analyzeSQLType(ATTR.ATTR_NAME, COLLECTION_TYPE_NAME, COLLECTION_TYPE_OWNER );
          ATTR_COUNT := ATTR_COUNT + CHILD_ATTR.extract('/' || CHILD_ATTR.GETROOTELEMENT()  || '/@sqlAttrs').getNumberVal();
          select appendChildXML(ATTR_DETAIL,XPATH_EXPRESSION,CHILD_ATTR)
            into ATTR_DETAIL
            from DUAL;
        exception
          when no_data_found then
            begin
              select 1
                into TEMP
                from ALL_TYPES
               where TYPE_NAME = ATTR.ATTR_TYPE_NAME
                and OWNER = ATTR.ATTR_TYPE_OWNER;
              CHILD_ATTR := analyzeSQLType(ATTR.ATTR_NAME, ATTR.ATTR_TYPE_NAME, ATTR.ATTR_TYPE_OWNER );
              ATTR_COUNT := ATTR_COUNT + CHILD_ATTR.extract('/' || CHILD_ATTR.GETROOTELEMENT() || '/@sqlAttrs').getNumberVal();
              select appendChildXML(ATTR_DETAIL,XPATH_EXPRESSION,CHILD_ATTR)
                into ATTR_DETAIL
                from DUAL;
            exception
             when no_data_found then
               ATTR_COUNT := ATTR_COUNT + 1;
            end;
        end;
      end loop;
      select insertChildXML(ATTR_DETAIL,XPATH_EXPRESSION,'@sqlAttrs',ATTR_COUNT)
        into ATTR_DETAIL
        from dual;
      return ATTR_DETAIL;
    end;
    function analyzeComplexType(COMPLEX_TYPE VARCHAR2)
    return XMLType
    as
      RESULT           xmltype;
      SQLTYPE          varchar2(128);
      SQLTYPE_OWNER    varchar2(32);
    begin
      select SQLTYPE, SQLTYPE_OWNER
        into SQLTYPE, SQLTYPE_OWNER
        from USER_XML_SCHEMAS,
             xmlTable
                xmlnamespaces
                  'http://www.w3.org/2001/XMLSchema' as "xsd",
                  'http://xmlns.oracle.com/xdb' as "xdb"
                '/xsd:schema/xsd:complexType'
                passing Schema
                columns
                COMPLEX_TYPE_NAME varchar2(4000) path '@name',
                SQLTYPE           varchar2(128)  path '@xdb:SQLType',
                SQLTYPE_OWNER     varchar2(32)   path '@xdb:SQLSchema'
       where COMPLEX_TYPE_NAME = COMPLEX_TYPE;
      result := analyzeSQLType(COMPLEX_TYPE,SQLTYPE,SQLTYPE_OWNER);
      select insertChildXML(RESULT,'/' || COMPLEX_TYPE,'@SQLType',SQLTYPE)
        into result
        from dual;
      return result;
    end;
    function showSQLTypes(schemaFolder varchar2) return XMLType
    is
      xmlSchema XMLTYPE;
    begin
      select xmlElement                                 
               "TypeList",                              
               xmlAgg                                   
                  xmlElement                             
                    "Schema",                            
                    xmlElement
                      "ResourceName",
                      extractValue(res,'/Resource/DisplayName')
                    xmlElement                         
                      "complexTypes",                  
                        select xmlAgg                               
                                 xmlElement              
                                   "complexType",        
                                   xmlElement           
                                     "name",             
                                     extractValue(value(XML),'/xsd:complexType/@name',XDB_NAMESPACES.XDBSCHEMA_PREFIXES)                          
                                   xmlElement            
                                     "SQLType",          
                                     extractValue(value(XML),'/xsd:complexType/@xdb:SQLType',XDB_NAMESPACES.XDBSCHEMA_PREFIXES)                            
                          from table                   
                                 xmlsequence           
                                   extract             
                                     xdburitype(p.path).getXML(),
                                     '/xsd:schema/xsd:complexType',
                                     XDB_NAMESPACES.XDBSCHEMA_PREFIXES
                               ) xml
                          -- order by extractValue(value(XML),'/xsd:complexType/@name',XDB_NAMESPACES.XDBSCHEMA_PREFIXES)
              ).extract('/*')                            
         into xmlSchema
         from path_view p                                
        where under_path(res,schemaFolder) = 1      
        order by extractValue(res,'/Resource/DisplayName');
      return xmlSchema;
    end;
    procedure renameCollectionTable (XMLTABLE varchar2, XPATH varchar2, COLLECTION_TABLE_PREFIX varchar2)
    as
       SYSTEM_GENERATED_NAME varchar2(256);
       COLLECTION_TABLE_NAME varchar2(256);
       CLUSTERED_INDEX_NAME  varchar2(256);
       PARENT_INDEX_NAME     varchar2(256);
       RENAME_STATEMENT varchar2(4000);
    begin
       COLLECTION_TABLE_NAME := COLLECTION_TABLE_PREFIX || '_TABLE';
       CLUSTERED_INDEX_NAME := COLLECTION_TABLE_PREFIX || '_DATA';
       PARENT_INDEX_NAME := COLLECTION_TABLE_PREFIX || '_LIST';
       select TABLE_NAME
         into SYSTEM_GENERATED_NAME
         from ALL_NESTED_TABLES
        where PARENT_TABLE_NAME = XMLTABLE
          and PARENT_TABLE_COLUMN = XPATH
          and OWNER = USER;
       RENAME_STATEMENT := 'alter table ' || USER || '."' || SYSTEM_GENERATED_NAME || '" rename to "' ||COLLECTION_TABLE_NAME || '"';
       -- -- dbms_output.put_line(RENAME_STATEMENT);
       execute immediate RENAME_STATEMENT;
       begin
         select INDEX_NAME
           into SYSTEM_GENERATED_NAME
           from ALL_INDEXES
          where TABLE_NAME = COLLECTION_TABLE_NAME
            and INDEX_TYPE = 'IOT - TOP'
            and OWNER = USER;
         RENAME_STATEMENT := 'alter index ' || USER || '."' || SYSTEM_GENERATED_NAME || '" rename to "' || CLUSTERED_INDEX_NAME || '"';
         -- -- dbms_output.put_line(RENAME_STATEMENT);
         execute immediate RENAME_STATEMENT;
       exception
         when NO_DATA_FOUND then
           null;
       end;
       begin
         select INDEX_NAME
           into SYSTEM_GENERATED_NAME
           from ALL_IND_columns
          where COLUMN_NAME = XPATH
            and TABLE_NAME =  XMLTABLE
            and TABLE_OWNER = USER;
         RENAME_STATEMENT := 'alter index ' || USER || '."' || SYSTEM_GENERATED_NAME || '" rename to "' || PARENT_INDEX_NAME || '"';
         -- -- dbms_output.put_line(RENAME_STATEMENT);
         execute immediate RENAME_STATEMENT;
       exception
         when NO_DATA_FOUND then
           null;
       end;
    end;
    function processNestedTable(currentLevel in out number, currentNode in out XMLType, query SYS_REFCURSOR)
    return XMLType
    is
      thisLevel  number;
      thisNode   xmlType;
      result xmlType;
    begin
      thisLevel := currentLevel;
      thisNode := currentNode;
      fetch query into currentLevel, currentNode;
      if (query%NOTFOUND) then
        currentLevel := -1;
      end if;
      while (currentLevel >= thisLevel) loop
        -- Next Node is a decendant of sibling of this Node.
        if (currentLevel > thisLevel) then
          -- Next Node is a decendant of this Node.
          result := processNestedTable(currentLevel, currentNode, query);
          select xmlElement
                    "Collection",
                    extract(thisNode,'/Collection/*'),
                    xmlElement
                      "NestedCollections",
                      result
             into thisNode
             from dual;
        else
          -- Next node is a sibling of this Node.
          result := processNestedTable(currentLevel, currentNode, query);
          select xmlconcat(thisNode,result) into thisNode from dual;
        end if;
      end loop;
      -- Next Node is a sibling of some ancestor of this node.
      return thisNode;
    end;
    function printNestedTables(XML_TABLE varchar2)
    return XMLType
    is
       query SYS_REFCURSOR;
       result XMLType;
       rootLevel number := 0;
       rootNode xmlType;
    begin
       open query for
            select level, xmlElement
                            "Collection",
                            xmlElement
                              "CollectionId",
                              PARENT_TABLE_COLUMN
                          ) as XML
              from USER_NESTED_TABLES
           connect by PRIOR TABLE_NAME = PARENT_TABLE_NAME
                   start with PARENT_TABLE_NAME = XML_TABLE;
        fetch query into rootLevel, rootNode;
        result := processNestedTable(rootLevel, rootNode, query);
        select xmlElement
                  "NestedTableStructure",
                  result
          into result
          from dual;
        return result;
    end;
    function generateSchemaFromTable(P_TABLE_NAME varchar2, P_OWNER varchar2 default USER)
    return XMLTYPE
    as
      xmlSchema XMLTYPE;
    begin
      select xmlElement
               "xsd:schema",
               xmlAttributes
                 'http://www.w3.org/2001/XMLSchema' as "xmlns:xsd",
                 'http://xmlns.oracle.com/xdb' as "xmlns:xdb"
               xmlElement
                 "xsd:element",
                 xmlAttributes
                   'ROWSET' as "name",
                   'rowset' as "type"
               xmlElement
                 "xsd:complexType",
                 xmlAttributes
                   'rowset' as "name"
                 xmlElement
                   "xsd:sequence",
                   xmlElement
                      "xsd:element",
                      xmlAttributes
                        'ROW' as "name",
                        table_name || '_T' as "type",
                        'unbounded' as "maxOccurs"
               xmlElement
                 "xsd:complexType",
                 xmlAttributes
                   table_name || '_T' as "name"
                 xmlElement
                   "xsd:sequence",
                     xmlAgg(ELEMENT order by INTERNAL_COLUMN_ID)
        into xmlSchema
        from (select TABLE_NAME, INTERNAL_COLUMN_ID,
                     case
                       when DATA_TYPE in ('VARCHAR2','CHAR') then
                         xmlElement
                           "xsd:element",
                           xmlattributes
                             column_name as "name",
                             decode(NULLABLE, 'Y', 0, 1) as "minOccurs",
                             column_name as "xdb:SQLName",
                             DATA_TYPE as "xdb:SQLType"
                           xmlElement
                             "xsd:simpleType",
                             xmlElement
                               "xsd:restriction",
                               xmlAttributes
                                 'xsd:string' as "base"
                               xmlElement
                                 "xsd:maxLength",
                                 xmlAttributes
                                   DATA_LENGTH  as "value"
                       when DATA_TYPE = 'NUMBER' then
                         xmlElement
                           "xsd:element",
                           xmlattributes
                             column_name as "name",
                             decode(NULLABLE, 'Y', 0, 1) as "minOccurs",
                             column_name as "xdb:SQLName",
                             DATA_TYPE as "xdb:SQLType"
                           xmlElement
                             "xsd:simpleType",
                             xmlElement
                               "xsd:restriction",
                               xmlAttributes
                                  decode(DATA_SCALE, 0, 'xsd:integer', 'xsd:double') as "base"
                               xmlElement
                                 "xsd:totalDigits",
                                 xmlAttributes
                                   DATA_PRECISION  as "value"
                       when DATA_TYPE = 'DATE' then
                         xmlElement
                           "xsd:element",
                           xmlattributes
                             column_name as "name",
                             decode(NULLABLE, 'Y', 0, 1) as "minOccurs",
                             'xsd:date' as "type",
                             column_name as "xdb:SQLName",
                             DATA_TYPE as "xdb:SQLType"
                       when DATA_TYPE like 'TIMESTAMP%WITH TIME ZONE' then
                         xmlElement
                           "xsd:element",
                           xmlattributes
                             column_name as "name",
                             decode(NULLABLE, 'Y', 0, 1) as "minOccurs",
                             'xsd:dateTime' as "type",
                             column_name as "xdb:SQLName",
                             DATA_TYPE as "xdb:SQLType"
                       else
                         xmlElement
                           "xsd:element",
                           xmlattributes
                             column_name as "name",
                             decode(NULLABLE, 'Y', 0, 1) as "minOccurs",
                             'xsd:anySimpleType' as "type",
                             column_name as "xdb:SQLName",
                             DATA_TYPE as "xdb:SQLType"
                     end ELEMENT
                from all_tab_cols c
               where c.TABLE_NAME = P_TABLE_NAME
                 and c.OWNER = P_OWNER
        group by TABLE_NAME;
      return xmlSchema;
    end;
    function appendElementList(V_ELEMENT_LIST IN OUT XDB.XDB$XMLTYPE_REF_LIST_T, V_CHILD_ELEMENT_LIST XDB.XDB$XMLTYPE_REF_LIST_T) return XDB.XDB$XMLTYPE_REF_LIST_T;
    function expandModel(P_MODEL XDB.XDB$MODEL_T) return XDB.XDB$XMLTYPE_REF_LIST_T;
    function expandChoiceList(P_CHOICE_LIST XDB.XDB$XMLTYPE_REF_LIST_T) return XDB.XDB$XMLTYPE_REF_LIST_T;
    function expandSequenceList(P_SEQUENCE_LIST XDB.XDB$XMLTYPE_REF_LIST_T) return XDB.XDB$XMLTYPE_REF_LIST_T;
    function expandGroupList(P_GROUP_LIST XDB.XDB$XMLTYPE_REF_LIST_T) return XDB.XDB$XMLTYPE_REF_LIST_T;
    function appendElementList(V_ELEMENT_LIST IN OUT XDB.XDB$XMLTYPE_REF_LIST_T, V_CHILD_ELEMENT_LIST XDB.XDB$XMLTYPE_REF_LIST_T)
    return XDB.XDB$XMLTYPE_REF_LIST_T
    as
    begin
      SELECT CAST
               SET
                 CAST(V_ELEMENT_LIST as XDBPM.XMLTYPE_REF_TABLE_T)
                 MULTISET UNION
                 CAST(V_CHILD_ELEMENT_LIST as XDBPM.XMLTYPE_REF_TABLE_T)
               as XDB.XDB$XMLTYPE_REF_LIST_T
        into V_ELEMENT_LIST
        from DUAL;
        return V_ELEMENT_LIST;     
    end;
    function expandModel(P_MODEL XDB.XDB$MODEL_T)
    return XDB.XDB$XMLTYPE_REF_LIST_T
    as
      V_ELEMENT_LIST       XDB.XDB$XMLTYPE_REF_LIST_T;
      V_CHILD_ELEMENT_LIST XDB.XDB$XMLTYPE_REF_LIST_T;
    begin
      V_ELEMENT_LIST := XDB.XDB$XMLTYPE_REF_LIST_T();
      if P_MODEL.ELEMENTS is not null then
        V_ELEMENT_LIST := P_MODEL.ELEMENTS;
      end if;
      if (P_MODEL.CHOICE_KIDS is not NULL) then
        V_CHILD_ELEMENT_LIST := expandChoiceList(P_MODEL.CHOICE_KIDS);
        V_ELEMENT_LIST := appendElementList(V_ELEMENT_LIST,V_CHILD_ELEMENT_LIST);
      end if;
      if (P_MODEL.SEQUENCE_KIDS is not NULL) then
        V_CHILD_ELEMENT_LIST := expandSequenceList(P_MODEL.SEQUENCE_KIDS);
        V_ELEMENT_LIST := appendElementList(V_ELEMENT_LIST,V_CHILD_ELEMENT_LIST);
      end if;
      -- Process ANYS
      if (P_MODEL.GROUPS is not NULL) then
        V_CHILD_ELEMENT_LIST := expandGroupList(P_MODEL.GROUPS);
        V_ELEMENT_LIST := appendElementList(V_ELEMENT_LIST,V_CHILD_ELEMENT_LIST);
      end if;
      return V_ELEMENT_LIST;
    end;
    function expandChoiceList(P_CHOICE_LIST XDB.XDB$XMLTYPE_REF_LIST_T)
    return XDB.XDB$XMLTYPE_REF_LIST_T
    as
      V_ELEMENT_LIST       XDB.XDB$XMLTYPE_REF_LIST_T;
      V_CHILD_ELEMENT_LIST XDB.XDB$XMLTYPE_REF_LIST_T;
      cursor getChoices is
      select c.XMLDATA MODEL
        from XDB.XDB$CHOICE_MODEL c, TABLE(P_CHOICE_LIST) cl
       where ref(c) = value(cl);
    begin
      V_ELEMENT_LIST := XDB.XDB$XMLTYPE_REF_LIST_T();
      for c in getChoices loop
        V_CHILD_ELEMENT_LIST := expandModel(c.MODEL);
        V_ELEMENT_LIST := appendElementList(V_ELEMENT_LIST,V_CHILD_ELEMENT_LIST);
      end loop;
      return V_ELEMENT_LIST;
    end;
    function expandSequenceList(P_SEQUENCE_LIST XDB.XDB$XMLTYPE_REF_LIST_T)
    return XDB.XDB$XMLTYPE_REF_LIST_T
    as
      V_ELEMENT_LIST       XDB.XDB$XMLTYPE_REF_LIST_T;
      V_CHILD_ELEMENT_LIST XDB.XDB$XMLTYPE_REF_LIST_T;
      cursor getSequences is
      select s.XMLDATA MODEL
        from XDB.XDB$SEQUENCE_MODEL s, TABLE(P_SEQUENCE_LIST) sl
       where ref(s) = value(sl);
    begin
      V_ELEMENT_LIST := XDB.XDB$XMLTYPE_REF_LIST_T();
      for s in getSequences loop
        V_CHILD_ELEMENT_LIST := expandModel(s.MODEL);
        V_ELEMENT_LIST := appendElementList(V_ELEMENT_LIST,V_CHILD_ELEMENT_LIST);
      end loop;
      return V_ELEMENT_LIST;
    end;
    function expandGroupList(P_GROUP_LIST XDB.XDB$XMLTYPE_REF_LIST_T)
    return XDB.XDB$XMLTYPE_REF_LIST_T
    as
      V_ELEMENT_LIST       XDB.XDB$XMLTYPE_REF_LIST_T;
      V_CHILD_ELEMENT_LIST XDB.XDB$XMLTYPE_REF_LIST_T;  V_MODEL  XDB.XDB$MODEL_T;
      cursor getGroups is
      SELECT CASE
               -- Return The MODEL Definition for the CHOICE, ALL or SEQUENCE
               WHEN gd.XMLDATA.ALL_KID is not NULL
                 THEN ( SELECT a.XMLDATA  from XDB.XDB$ALL_MODEL a where ref(a) = gd.XMLDATA.ALL_KID)
               WHEN gd.XMLDATA.SEQUENCE_KID is not NULL
                 THEN ( SELECT s.XMLDATA  from XDB.XDB$SEQUENCE_MODEL s where ref(s) = gd.XMLDATA.SEQUENCE_KID)
               WHEN gd.XMLDATA.CHOICE_KID is not NULL
                 THEN ( SELECT c.XMLDATA  from XDB.XDB$CHOICE_MODEL c where ref(c) = gd.XMLDATA.CHOICE_KID)
              END MODEL
         FROM XDB.XDB$GROUP_DEF gd, XDB.XDB$GROUP_REF gr, TABLE(P_GROUP_LIST) gl
        WHERE ref(gd) = gr.XMLDATA.GROUPREF_REF
          and ref(gr) = value(gl);
    begin
      V_ELEMENT_LIST := XDB.XDB$XMLTYPE_REF_LIST_T();
      for g in getGroups loop
        V_CHILD_ELEMENT_LIST := expandModel(g.MODEL);
        V_ELEMENT_LIST := appendElementList(V_ELEMENT_LIST,V_CHILD_ELEMENT_LIST);
      end loop;
      return V_ELEMENT_LIST;
    end;
    function getComplexTypeElementList(P_COMPLEX_TYPE_REF REF XMLTYPE)
    return XDB.XDB$XMLTYPE_REF_LIST_T
    as
      V_MODEL        XDB.XDB$MODEL_T;
      V_BASE_TYPE    REF XMLTYPE;
      V_ELEMENT_LIST XDB.XDB$XMLTYPE_REF_LIST_T := XDB.XDB$XMLTYPE_REF_LIST_T();
    begin
      SELECT ct.XMLDATA.BASE_TYPE,
             CASE
               -- Return The MODEL Definition for the CHOICE, ALL or SEQUENCE
               WHEN ct.XMLDATA.ALL_KID is not NULL
                 THEN ( SELECT a.XMLDATA  from XDB.XDB$ALL_MODEL a where ref(a) = ct.XMLDATA.ALL_KID)
               WHEN ct.XMLDATA.SEQUENCE_KID is not NULL
                 THEN ( SELECT s.XMLDATA  from XDB.XDB$SEQUENCE_MODEL s where ref(s) = ct.XMLDATA.SEQUENCE_KID)
               WHEN ct.XMLDATA.CHOICE_KID is not NULL
                 THEN ( SELECT c.XMLDATA  from XDB.XDB$CHOICE_MODEL c where ref(c) = ct.XMLDATA.CHOICE_KID)
               WHEN ct.XMLDATA.GROUP_KID is not NULL
                 -- COMPLEXTYPE is based on a GROUP.
                 THEN (
                         -- RETURN The CHOICE, ALL or SEQUENCE for GROUP
                         SELECT CASE
                                  WHEN gd.XMLDATA.ALL_KID is not NULL
                                    THEN ( SELECT a.XMLDATA  from XDB.XDB$ALL_MODEL a where ref(a) = gd.XMLDATA.ALL_KID)
                                  WHEN gd.XMLDATA.SEQUENCE_KID is not NULL
                                    THEN ( SELECT s.XMLDATA  from XDB.XDB$SEQUENCE_MODEL s where ref(s) = gd.XMLDATA.SEQUENCE_KID)
                                  WHEN gd.XMLDATA.CHOICE_KID is not NULL
                                    THEN ( SELECT c.XMLDATA  from XDB.XDB$CHOICE_MODEL c where ref(c) = gd.XMLDATA.CHOICE_KID)
                                  END
                             FROM XDB.XDB$GROUP_DEF gd, xdb.xdb$GROUP_REF gr
                            WHERE ref(gd) = gr.XMLDATA.GROUPREF_REF
                              and ref(gr) = ct.XMLDATA.GROUP_KID
    --           WHEN ct.XMLDATA.COMPLEXCONTENT.RESTRICTION.ALL_KID is not NULL
    --             THEN ( SELECT a.XMLDATA  from XDB.XDB$ALL_MODEL a where ref(a) = ct.XMLDATA.COMPLEXCONTENT.RESTRICTION.ALL_KID)
    --           WHEN ct.XMLDATA.COMPLEXCONTENT.RESTRICTION.SEQUENCE_KID is not NULL
    --            THEN ( SELECT s.XMLDATA  from XDB.XDB$SEQUENCE_MODEL s where ref(s) = ct.XMLDATA.COMPLEXCONTENT.RESTRICTION.SEQUENCE_KID)
    --           WHEN ct.XMLDATA.COMPLEXCONTENT.RESTRICTION.CHOICE_KID is not NULL
    --             THEN ( SELECT c.XMLDATA  from XDB.XDB$CHOICE_MODEL c where ref(c) = ct.XMLDATA.COMPLEXCONTENT.RESTRICTION.CHOICE_KID)
    --           WHEN ct.XMLDATA.COMPLEXCONTENT.RESTRICTION.GROUP_KID is not NULL
    --             -- COMPLEXTYPE is based on a GROUP.
    --             THEN (
    --                     -- RETURN The CHOICE, ALL or SEQUENCE for GROUP
    --                     SELECT CASE
    --                              WHEN gd.XMLDATA.ALL_KID is not NULL
    --                                THEN ( SELECT a.XMLDATA  from XDB.XDB$ALL_MODEL a where ref(a) = gd.XMLDATA.ALL_KID)
    --                              WHEN gd.XMLDATA.SEQUENCE_KID is not NULL
    --                                THEN ( SELECT s.XMLDATA  from XDB.XDB$SEQUENCE_MODEL s where ref(s) = gd.XMLDATA.SEQUENCE_KID)
    --                              WHEN gd.XMLDATA.CHOICE_KID is not NULL
    --                                THEN ( SELECT c.XMLDATA  from XDB.XDB$CHOICE_MODEL c where ref(c) = gd.XMLDATA.CHOICE_KID)
    --                              END
    --                         FROM XDB.XDB$GROUP_DEF gd, xdb.xdb$GROUP_REF gr
    --                       WHERE ref(gd) = gr.XMLDATA.GROUPREF_REF
    --                          and ref(gr) = ct.XMLDATA.COMPLEXCONTENT.RESTRICTION.GROUP_KID
               WHEN ct.XMLDATA.COMPLEXCONTENT.EXTENSION.ALL_KID is not NULL
                 THEN ( SELECT a.XMLDATA  from XDB.XDB$ALL_MODEL a where ref(a) = ct.XMLDATA.COMPLEXCONTENT.EXTENSION.ALL_KID)
               WHEN ct.XMLDATA.COMPLEXCONTENT.EXTENSION.SEQUENCE_KID is not NULL
                 THEN ( SELECT s.XMLDATA  from XDB.XDB$SEQUENCE_MODEL s where ref(s) = ct.XMLDATA.COMPLEXCONTENT.EXTENSION.SEQUENCE_KID)
               WHEN ct.XMLDATA.COMPLEXCONTENT.EXTENSION.CHOICE_KID is not NULL
                 THEN ( SELECT c.XMLDATA  from XDB.XDB$CHOICE_MODEL c where ref(c) = ct.XMLDATA.COMPLEXCONTENT.EXTENSION.CHOICE_KID)
               WHEN ct.XMLDATA.COMPLEXCONTENT.EXTENSION.GROUP_KID is not NULL
                 -- COMPLEXTYPE is based on a GROUP.
                 THEN (
                         -- RETURN The CHOICE, ALL or SEQUENCE for GROUP
                         SELECT CASE
                                  WHEN gd.XMLDATA.ALL_KID is not NULL
                                    THEN ( SELECT a.XMLDATA  from XDB.XDB$ALL_MODEL a where ref(a) = gd.XMLDATA.ALL_KID)
                    

  • EJB 3.0 Web Services - Custom Request/Response Wrappers

    Hi All,
    I'm having an issue using Document Literal Wrapped web services with EJB 3.0. I have declared a service endpoint interface(SEI) in one jar file, along with custom wrapper classes for the requests and responses. The wrappers have the XML content customized a bit (different type names, etc.), but should be compatible with the @RequestWrapper and @ResponseWrapper annotations. The implementation is in an EJB jar file that includes the jar with the SEI in it. My issue is that the wrapper classes I declared are not being used, and instead new ones are being generated. Is it even possible for it to use supplied wrappers, or does it have to generate its own (and if so, is it in any way possible to specify the XML types it generates). I've tested this with wsgen, and I get the same result (new wrapper classes, the ones I supplied ignored) as when I deploy it. Here is the output from wsgen:
    Note: ap round: 1
    [ProcessedMethods Interface: com.company.IngestorService]
    [should process method: ingestProductDirectory hasWebMethods: false ]
    [endpointReferencesInterface: true]
    [declaring class has WebSevice: true]
    [returning: true]
    [WrapperGen - method: ingestProductDirectory(java.lang.String,java.lang.String)]
    [method.getDeclaringType(): com.company.IngestorService]
    [requestWrapper: com.company.IngestProductDirectoryRequest]
    [should process method: datatypes hasWebMethods: false ]
    [endpointReferencesInterface: true]
    [declaring class has WebSevice: true]
    [returning: true]
    [WrapperGen - method: datatypes()]
    [method.getDeclaringType(): com.company.IngestorService]
    [requestWrapper: com.company.DatatypesRequest]
    com\company\DatatypesRequest.java
    com\company\DatatypesResponse.java
    com\company\IngestProductDirectoryRequest.java
    com\company\IngestProductDirectoryResponse.java
    Note: ap round: 2
    I note that is says "hasWebMethods: false". Could that be an issue? Could it not be seeing my methods as web methods. The SEI and the implementation class are in different jar files and different packages. Could this be an issue?
    Here is the web service interface:
    @WebService(
    name = "IngestorService",
    targetNamespace = "http://company.com/"
    @SOAPBinding(
    style = SOAPBinding.Style.DOCUMENT,
    parameterStyle = SOAPBinding.ParameterStyle.WRAPPED
    public interface IngestorService
    @WebMethod(
    action = "http://company.com/ingestProductDirectory"
    @WebResult(
    name = "response",
    targetNamespace = ""
    @RequestWrapper(
    className = "com.company.IngestProductDirectoryRequest"
    @ResponseWrapper(
    className = "com.company.IngestProductDirectoryResponse"
    public void ingestProductDirectory(
    @WebParam(
    name = "sourceDirectory",
    targetNamespace = ""
    String sourceDirectory,
    @WebParam(
    name = "datatype",
    targetNamespace = ""
    String datatype);
    @WebMethod(
    operationName = "datatypes",
    action = "http://company.com/datatypes"
    @WebResult(
    name = "datatypes",
    targetNamespace = ""
    @RequestWrapper(
    localName = "DatatypesRequest",
    className = "com.company.DatatypesRequest"
    @ResponseWrapper(
    localName = "DatatypesResponse",
    className = "com.company.DatatypesResponse"
    public List datatypes();
    Here are the datatype request and response wrappers:
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(
    name = "DatatypesRequest"
    public class DatatypesRequest
    DatatypesResponse.java:
    @XmlAccessorType(XmlAccessType.PROPERTY)
    @XmlType(
    name = "DatatypesResponse",
    propOrder =
    "datatypes"
    public class DatatypesResponse
    private List<String> _datatypes;
    @XmlElementWrapper(
    name = "datatypes",
    required = true,
    nillable = false
    @XmlElement(
    name = "datatype",
    required = false
    public List<String> getDatatypes() {
    if (_datatypes == null) {
    _datatypes = new ArrayList<String>();
    return _datatypes;
    Any help would be greatly appreciated. Thanks.

    I have been trying to do the same... and it seems to be impossible... (or completly undocumented).
    It seems that OC4J 10.3.x is ... no exactly fully EJB3/J2EE5 compliant...
    Or something like that:
    http://blogs.infosupport.com/berte/archive/2005/09/09/1117.aspx
    IMHO... OC4J 10.3.x is still a preview for OC4J 11...
    OC4J 10.3.x is kind of a J2EE4/5 hybrid... if you start digging in the documentation, you will find out that the only
    way to have WS-Security is going back to J2EE4 http://www.oracle.com/technology/products/jdev/howtos/1013/wssecure/10gwssecurity_howto.html
    (of course, I hope you probe me wrong)
    Message was edited by:
    luxspes

Maybe you are looking for

  • How do I install a second Java instance in a Distributed Installation?

    Hello all, I've just completed the Distributed Installation of a WAS Java stack.  The Central Services and Database are running on one box and the Central Instance (01) is running on antoher box. I want to add a second instance (02) on another physic

  • Defective maybe?

    I just bought my iPod last night. I read and followed the directions to a T. But my computer said the USB port device was corrupt and there was no driver. Meantime, it freezes my iPod. I read everything on the site that regards to resetting an iPod a

  • Formatting quiz questions

    I've created a quiz and found that the formatting for the questions is inconsistent and doesn't fit my slides well. For example, the width of the answers "blocks" are too narrow -- they don't fill the slide width well. And some of the font sizes are

  • Lost Photo after changing photo file name

    Due to duplicate file name, e.g. P1002534.jpg in my photos, I was trying to rename some of them to a different name. I did that through Finder and other tools (e.g. Renamer) but apply directly to /iphoto libray/original or /iphoto libray/modified lib

  • Help about the query

    Hi, I have table MYTABLE like Text - Name 'ABC' first 'DEF' second How can I get Query result 'ABCDEF' Thanks a lot