Number of columns in a legend

Hi!
I need a chart legend with 4 columns, but I couldn't find where I can set this option. Is it possible? I can only change the legend position.
I'm using OBIEE 11.1.1.6.6
Thanks.

Hi!
Actually, I'm using a trellis view with a bubble chart. My legend has 4 values, and I want it stays below the trellis with 4 columns and just 1 line. The problem is the legend is shown with 2 columns and 2 lines, and I couldn't find a way to change this.
The legend should be just below the trellis, like the X axis.
Thanks.

Similar Messages

  • How to find the number of columns in an internal table DYNAMICALLY ?

    Hi,
    How to find the number of columns in an internal table DYNAMICALLY ?
    Thanks and Regards,
    saleem.

    Hi,
    you can find the number of columns and their order using
    the <b>'REUSE_ALV_FIELDCATALOG_MERGE'</b>
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = sy-repid
       I_INTERNAL_TABNAME           = 'ITAB'
       I_INCLNAME                   = sy-repid
      changing
        ct_fieldcat                  = IT_FIELDCAT
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif
    now describe your fieldcat . and find no of columns.
    and their order also..
    regards
    vijay

  • Is their any limit on the number of column updates in a update statement!

    Hello All,
    Is their any limit on the number of columns to set in a single update statement.+
    am using oracle 11g .
    example :-
    UPDATE FMLY SET as_comp1 = v_as_comp1 , as_comp2 = v_as_comp2, as_comp3 = v_as_comp3, as_comp4 = v_as_comp4 , as_comp5 = v_as_comp5 ,      perslt18 = v_perslt18 , persot64  = v_persot64  , fam_size = v_fam_size , numchild = total_children , C_AGE1 = v_c_age1,  C_AGE2 = v_c_age2,  C_AGE3 = v_c_age3,  C_AGE4 = v_c_age4 WHERE FAMID = fmly_famid(i) ;
    and also is it good practice to issue single update or multiple updates ?
    example for the above update i can have multiple statements like .. does the performance matters if so which is good
    UPDATE FMLY SET as_comp1 = v_as_comp1 , as_comp2 = v_as_comp2, as_comp3 = v_as_comp3, as_comp4 = v_as_comp4 , as_comp5 = v_as_comp5
    WHERE FAMID = fmly_famid(i) ;
    UPDATE FMLY SET perslt18 = v_perslt18 , persot64 = v_persot64 , fam_size = v_fam_size
    WHERE FAMID = fmly_famid(i) ;
    UPDATE FMLY SET numchild = total_children WHERE FAMID = fmly_famid(i) ;
    UPDATE FMLY SET C_AGE1 = v_c_age1, C_AGE2 = v_c_age2, C_AGE3 = v_c_age3, C_AGE4 = v_c_age4 WHERE FAMID = fmly_famid(i) ;
    thanks/kumar
    Edited by: kumar73 on Sep 25, 2010 8:38 AM

    If you can do it in a single SQL statement then you should do that.
    Here's a mantra that I found to work out pretty good:
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:73891904732164

  • Number of columns and effect on performance

    We are trying to improve the performance of our system and have noticed that the number of columns in our select statements has a dramatic, non-linear effect on the performance we see. For a particular query (with a single record returned) retrieving 10 columns from the table takes about 120 milliseconds, but if we reduce the request to 6 columns the time shrinks to about 18 milliseconds. It doesn't seem to matter which columns we pick, just how many of them are chosen.
    We have even been able to retrieve a large number of columns from a table using multiple requests of 5 columns each and see a 2X performance improvement over a single request for all of the columns. Use of prepared statements and setting column types seems to have negligible effect.
    Any ideas what we are seeing here and how we might improve the performance without cluttering our code up with these wierd multiple requests? This is happening in the middle of a large system, with a number of other database requests happening other than the ones we have currently instrumented for performance measurements. Don't know if this is some kind of interaction with a cache or what. We are using Oracle 8i Enterprise Edition version 8.1.6.3.0.

    Hi,
    1) This forum provides a search option, you should use it  Doing so you will find this post
    2) Did you solve your earlier questions? If yes, you should mark the answers that helped you find a solution.

  • ALV report shows fixed number of columns for a user ?

    Hello,
    I have an issue wherein I have created an ABAP ALV grid display in a WD ABAP application and hosted it onto portal. Now, all the users can see the correct number of columns for the report which are determined dynamically. But just for one user, irrespective of which report she launches it shows her only 4 columns.
    Can anybody suggest why this kind of behavior.
    Appreciate your help.
    Regards,
    Samta.

    Hi,
    Right, click the button "manage layout" or "save layout" and remove any default user settings...
    added: didn't read carefully sorry ;)... better check user settings in SU01 if no ALV parameter is used.
    Kr,
    m.
    Edited by: Manu D'Haeyer on Oct 21, 2011 8:53 PM

  • Alv report with varying number of columns

    hi all,
    I am new to abap. I am writing this to get a brief idea of what i wanted to do in system.
    I have to do a report using alv.  The format of the report looks like this.
    acc no     acc. name     amt_sum_april   amt_sum_may   amt_sum_june. ............. total_months
    the colum amt_sum_ depends on user input period(month interval).
    if the user selects 4 to 6 = 3 columns ,if the user selects 4 to 10 = 7 columns
    so on.......
    Anyone have idea how to do it, because in the
    initial structure or itab, the number of columns depends on the user input.. i am stucking here ...
    pls help.
    thanks and regards
    jose

    Hi friend,
    It's very complicated to do that, I'm sure there's a way to do it but I really don't know it. Once I had a similar requirement and I did something else that solved my problem without making a fussy complicated code. I added a colum MONTH or PERIOD (depending on your requirement) and then I make a subtotal by that column. So you need:
    acc no acc. name amt_sum_april amt_sum_may amt_sum_june. ............. total_months
    Now you would have:
    acc no acc. name    month     amount
    In the SORT table, in the sorting condition by MONTH you specify SUBTOTAL = 'X'. So the output will be:
    acc no acc. name    month     amount
    123123        John      2            100.00
    123124        Paul      2            200.00
    Month  2                                300.00
    123123        John      3            300.00
    123124        Paul      3            400.00
    123125        Jane      3            100.00
    Month  3                                 800.00
    123123        John      4            123.54
    Month   4                                123.54
    Total                                      1223.54
    You can change the subtotal text for a more adequate one (if you want). Also if you only need the subtotals you can specify in the layout that only those lines are to be output.
    I hope I've helped, I you have any question let me know!
    Regards,
    Pablo

  • How to count number of columns in cross-tab report

    I have created a cross-tab report and have managed to get the data out as below:
                 Jan     Feb     Mar....(display of months will auto expand) Avg/Mo  Total
    UserA     4          3        4                                                                         11
    UserB     6          1        1                                                                          8
    UserC     5          5        5                                                                         15
    Total       15        9        10                                                                        33 
    I want to insert a calculated column (Avg/Mo) into the cross-tab report based on the formula: Total/Number of Months. I used this calculation formula  for Avg.Mo column:
    (GridValueAt(CurrentRowIndex, CurrentColumnIndex+1, CurrentSummaryIndex)/GetNumColumns)
    However, I get the wrong average since GetNumColumns count the total number of columns including the column of Avg/Mo and Total.
    How do i get the number of columns, excluding the Avg/Mo calculated column and Total column?
    PS: I can't use hardcode since the number of months/columns will auto expand the months progress...
    Edited by: jutamind on May 26, 2010 9:27 AM

    ok managed to solve this by slightly changing the formula:
    GridValueAt(CurrentRowIndex, CurrentColumnIndex+1, CurrentSummaryIndex)/(GetNumColumns-2)

  • 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)
                    

  • Maximum number of columns  in a table or view is 1000

    Post Author: TinaReifer
    CA Forum: Formula
    I am trying to create a direct link from Tririga / Oracle database into Crystal XI.  The data I am attempting to pull is from the RETransaction (Escalations). The error I keep receiving is shown below.  Has anyone run across this problem and found a solution that can be shared?
    Very Appreciative for any feedback.
    Tina Reifer
    "Failed to retrieve data from the database.
    Details: HY000:&#91;Oracle&#93;&#91;ODBC&#93;&#91;Ora&#93;ORA-01792: maximum number of columns  in a table or view is 1000
    &#91;Database Vendor Code:  1792&#93;"

    Post Author: synapsevampire
    CA Forum: Formula
    Try posting your software, its version, and the type of connectivity you're using for oracle.
    Older versions of Crystal used a proprietary Oracle ODBC driver that came with Crystal, but you should SWITCH away from using ODBC anyway, not sure why you elected to use it, it's slower and more problematic.
    You'll see Oracle Server listed as a data source, that is generally the best connectivity to use.
    Also, what version of Oracle is it, and what Oracle client are you using?
    You might need your Oracle dbas assistance here.
    Anyway, the error is not a Crystal error, it's being raised by the ODBC driver, and Oracle used to have a maximum of 1024 colums I think it was...been a while...
    -k

  • How to create a table with varied number of columns?

    I am trying to create a balance table. The colunms should include years between the start year and end year the user will input at run time. The rows will be the customers with outstanding balance in those years.
    If the user input years 2000 and 2002, the table should have columns 2000, 2001, 2002. But if the user input 2000 and 2001, the table will only have columns 2000 and 2001.
    Can I do it? How? Thanka a lot.

    Why did you create a new thread for this?
    How to create a table with varied number of columns?

  • How to get the number of columns in a result set???

    hi everyone..
    i am trying to establish a servlet applet communication....
    my applet send the sql query to the servlet as serialised string and then the servlet executes the query...
    Since i need to pass the result back to the applet, i thaught of passing the whole reult set to the applet..but that seems to be not possible..
    so i thaught of storing my result set data in a vector and then pass the vector,but the first problem that i came across is that how to get the number of colums in a result set....
    so is there a way to get the number of columns in a result set...???
    and also i would like to know if it possible to send my whole result set to the applet bye serialization or by any method...???
    thanx in advance

    You shouldn't do. It expenses resources (you should always close the ResultSet and the Statement as fast as possible). Simply gently process it into a Collection or Map of DTO's. Those are serializable.

  • How to show data from a table having large number of columns

    Hi ,
    I have a report with single row having large number of columns . I have to use a scroll bar to see all the columns.
    Is it possible to design report in below format(half columns on one side of page, half on other side of page :
    Column1
    Data
    Column11
    Data
    Column2
    Data
    Column12
    Data
    Column3
    Data
    Column13
    Data
    Column4
    Data
    Column14
    Data
    Column5
    Data
    Column15
    Data
    Column6
    Data
    Column16
    Data
    Column7
    Data
    Column17
    Data
    Column8
    Data
    Column18
    Data
    Column9
    Data
    Column19
    Data
    Column10
    Data
    Column20
    Data
    I am using Apex 4.2.3 version on oracle 11g xe.

    user2602680 wrote:
    Please update your forum profile with a real handle instead of "user2602680".
    I have a report with single row having large number of columns . I have to use a scroll bar to see all the columns.
    Is it possible to design report in below format(half columns on one side of page, half on other side of page :
    Column1
    Data
    Column11
    Data
    Column2
    Data
    Column12
    Data
    Column3
    Data
    Column13
    Data
    Column4
    Data
    Column14
    Data
    Column5
    Data
    Column15
    Data
    Column6
    Data
    Column16
    Data
    Column7
    Data
    Column17
    Data
    Column8
    Data
    Column18
    Data
    Column9
    Data
    Column19
    Data
    Column10
    Data
    Column20
    Data
    I am using Apex 4.2.3 version on oracle 11g xe.
    Yes, this can be achieved using a custom named column report template.

  • How can i export the data to excel which has 2 tables with same number of columns & column names?

    Hi everyone, again landed up with a problem.
    After trying a lot to do it myself, finally decided to post here..
    I have created a form in form builder 6i, in which on clicking a button the data gets exported to excel sheet.
    It is working fine with a single table. The problem now is that i am unable to do the same with 2 tables.
    Because both the tables have same number of columns & column names.
    Below are 2 tables with column names:
    Table-1 (MONTHLY_PART_1)
    Table-2 (MONTHLY_PART_2)
    SL_NO
    SL_NO
    COMP
    COMP
    DUE_DATE
    DUE_DATE
    U-1
    U-1
    U-2
    U-2
    U-4
    U-4
    U-20
    U-20
    U-25
    U-25
    Since both the tables have same column names, I'm getting the following error :
    Error 402 at line 103, column 4
      alias required in SELECT list of cursor to avoid duplicate column names.
    So How can i export the data to excel which has 2 tables with same number of columns & column names?
    Should i paste the code? Should i post this query in 'SQL and PL/SQL' Forum?
    Help me with this please.
    Thank You.

    You'll have to *alias* your columns, not prefix it with the table names:
    $[CHE_TEST@asterix1_impl] r
      1  declare
      2    cursor cData is
      3      with data as (
      4        select 1 id, 'test1' val1, 'a' val2 from dual
      5        union all
      6        select 1 id, '1test' val1, 'b' val2 from dual
      7        union all
      8        select 2 id, 'test2' val1, 'a' val2 from dual
      9        union all
    10        select 2 id, '2test' val1, 'b' val2 from dual
    11      )
    12      select a.id, b.id, a.val1, b.val1, a.val2, b.val2
    13      from data a, data b
    14      where a.id = b.id
    15      and a.val2 = 'a'
    16      and b.val2 = 'b';
    17  begin
    18    for rData in cData loop
    19      null;
    20    end loop;
    21* end;
      for rData in cData loop
    ERROR at line 18:
    ORA-06550: line 18, column 3:
    PLS-00402: alias required in SELECT list of cursor to avoid duplicate column names
    ORA-06550: line 18, column 3:
    PL/SQL: Statement ignored
    $[CHE_TEST@asterix1_impl] r
      1  declare
      2    cursor cData is
      3      with data as (
      4        select 1 id, 'test1' val1, 'a' val2 from dual
      5        union all
      6        select 1 id, '1test' val1, 'b' val2 from dual
      7        union all
      8        select 2 id, 'test2' val1, 'a' val2 from dual
      9        union all
    10        select 2 id, '2test' val1, 'b' val2 from dual
    11      )
    12      select a.id a_id, b.id b_id, a.val1 a_val1, b.val1 b_val1, a.val2 a_val2, b.val2 b_val2
    13      from data a, data b
    14      where a.id = b.id
    15      and a.val2 = 'a'
    16      and b.val2 = 'b';
    17  begin
    18    for rData in cData loop
    19      null;
    20    end loop;
    21* end;
    PL/SQL procedure successfully completed.
    cheers

  • XML Parsing Error: no element found Location:Line Number 1, Column 1:

    Hi,
    i have a servlet code in which i am using bouncy castle encryption algorithm , if i tried to run that servlet on embeded weblogic server than my servlet works fine without error.
    but if i deploy same Servlet code on SOA domain console than i get following error.
    XML Parsing Error: no element found
    Location: http://localhost:7001/Encryption-PGPEncrypt-context-root/pgpservlet
    Line Number 1, Column 1:
    Please help me friends...

    Hi Chandra,
    Based on my research, the error message is only generated by FireFox when the render page is blank in Internet. For some reason, .NET generates a response type of "application/xml" when it creates an empty page. Firefox parses the file as XML and finding
    no root element, spits out the error message.
    Also, based on your description, the other sites are opened correctly, the issue only happened in Central Administration(CA). This means the SharePoint services are working fine.
    Since this issue only occurred in the CA, it might be due the application pool for the CA is corrupted. Please try to restart the application pool for the CA to resove the issue:
    1. Open Internet Information Service(IIS)
    2. List the application pools
    3. Select the application pool used for the CA
    4. Stop it, and then start it again.
    Note, if the application pool is running in Classic mode, please change it to be Integrated mode.
    Additionally, I found a similar thread, which may help you too:
    http://social.msdn.microsoft.com/Forums/en/sharepoint2010general/thread/824d7dda-db03-452b-99c4-531c5c576396
    If you have any more questions, please feel free to ask.
    Thanks,
    Jin Chen
    Jin Chen - MSFT

  • XML Parsing Error: no element found Line Number 1, Column 1:

    Hi All,
    I have deployed EAR on my standalone server using JDEV 11.1.1.6.0. I am able to get the WSRP portlet producer page on
    http://<server>:7001/contextRoot. But when i try to click on any of the WSDL URL it gives me "XML Parsing Error: no element found Line Number 1, Column 1:"
    and from IE it gives me: XML document must have a top level element. Error processing resource
    there can be a issue with the WSRPContainer.jar file. So i have remove it from my deployment profile, EAR and lib/classpath files.
    Can you please suggest a workaround.
    Regards,
    ND
    Edited by: ND on Dec 4, 2012 9:57 PM

    Hi All,
    this error normally comes when the WLS domain is not not properly created. if you get some exception for ./provesecurity.sh file while creating the domain, then the XML error comes.
    I did not went into the depth but figured out a workaround: restart the VM/hosted box and then create the domain, remember to use diff port name while creating it from the domain creation script.
    Regards,
    ND

Maybe you are looking for

  • Replacing image in shared photo stream

    Is there a way to replace a photo in a shared photo stream and keep the original place in the stream? The only way I can find is to delete it and re-upload, but this will place the photo as the last photo in the stream.

  • Music Streaming Dropouts

    I have started getting extended dropouts during music streaming from iMac to Apple TV. It starts off as a glitchy sound until it finally goes quiet. It will then start back up about 20 seconds where if left off. Appears to be happening in about one m

  • The apps wont open but are fully updated in the creative cloud manager menu, how do I get them to open?

    the apps wont open but are fully updated in the creative cloud manager menu, how do I get them to open?

  • Perspective Transform in Javascript

    Hej everyone, I'm working on a script, which should do an automatic perspective correction. Unfortunately the only way I found out until now is some code, generated with the ScriptListener Plugin - and I am having a hard time figuring out what the va

  • How to check whether system privilege are granted

    How to check whether system privileges like 'create session' and other ones are granted for user. Is there any sys table where this information is available? Regards - Neuron