Help with constraints on object relational tables

Hi
I am looking to create an object relational database with a check constraint on the relationships. For example:
* I have table called person_tab which is a table of person_t type.
* Person_t type is inherited by the manager_t type and the applicant_t type.
* I have a second table called interview_tab of interview_t type.
* The interview table has two columns (manager and appilcant) that are scope restrained to the person table.
* I would also like to put check constraints on these columns to say:
----- Manager: check the person_number is less than 20000
----- Applicant: check the person_number is greater than 19999
Can anyone tell me if this is possible and if so how can it be done?
Thanks in advance
Stephen

You have circular dependencies (manager_t depends upon interview_list_t depends upon interview_t depends upon manager_t) which I don't think is a good idea. But then that's probably just my old-fashioned relational head baulking at this new-fangled OO way of looking at data models. However, my experience with using types and subtypes in Oracle does teach me that this is a complete pain in the neck, because it makes changing your Type definitions a very awkward process.
am I right in saying I cannot use the check constraint?I think so. If the value range for ID is a property of being a Manager or an Applicant then properly that should be enforced by those types not by the Interview type. Then all that Interviews needs to worry about is that it gets instantiated with attributes of the correct Type.
I've simplified your model a bit. To start with I'm going to create a single PERSONS table to store both managers and applicants...
SQL> CREATE TYPE person_t AS OBJECT (
  2  personno NUMBER,
  3  surname VARCHAR2(30),
  4  forename VARCHAR2(30),
  5  dob DATE
  6  ) NOT FINAL;
  7  /
Type created.
SQL>
SQL> CREATE OR REPLACE TYPE applicant_t UNDER person_t
  2  (qualifications varchar2(200))
  3  FINAL ;
  4  /
Type created.
SQL>
SQL> CREATE OR REPLACE TYPE manager_t UNDER person_t
  2  (extension varchar2(5)) FINAL;
  3  /
Type created.
SQL>
SQL> CREATE OR REPLACE TYPE interview_t AS OBJECT (
  2  interviewno NUMBER,
  3  idate DATE,
  4  itime NUMBER,
  5  interest NUMBER,
  6  is_made_by REF manager_t,
  7  attended_by REF applicant_t
  8  ) ;
  9  /
Type created.
SQL>
SQL>
SQL> CREATE TABLE persons OF person_t
  2  /
Table created.
SQL> CREATE TABLE interviews OF interview_t
  2  /
Table created.
SQL> Okay let's create some objects...
SQL> declare
  2     mgr manager_t := manager_t(1,'RUNCITER', 'GLEN', sysdate - (42*365), 'x1234');
  3     app applicant_t := applicant_t(2,  'CHIP', 'JOE', sysdate - (38*365), 'BSc, MSc');
  4     intv interview_t;
  5     m_ref REF  person_t;
  6     a_ref REF person_t;
  7  begin
  8     INSERT INTO persons p VALUES mgr
  9         RETURNING REF(p) INTO m_ref   ;
10     INSERT INTO persons p VALUES app
11         RETURNING REF(p) INTO a_ref   ;
12     insert into interviews
13     values (interview_t(1001, sysdate, 45, 5, TREAT(m_ref AS REF manager_t)
        , TREAT(a_ref AS REF applicant_t)));
14  end;
15  /
PL/SQL procedure successfully completed.
SQL> SELECT i.interviewno, i.is_made_by.surname, i.attended_by.surname
  2  FROM interviews i
  3  /
INTERVIEWNO IS_MADE_BY.SURNAME             ATTENDED_BY.SURNAME                 
       1001 RUNCITER                       CHIP                                
SQL> Have we got integrity?
SQL> rollback
  2  /
Rollback complete.
SQL>
SQL> declare
  2     mgr manager_t := manager_t(1,'RUNCITER', 'GLEN', sysdate - (42*365), 'x1234');
  3     app applicant_t := applicant_t(2,  'CHIP', 'JOE', sysdate - (38*365), 'BSc, MSc');
  4     intv interview_t;
  5     m_ref REF  person_t;
  6     a_ref REF person_t;
  7  begin
  8     INSERT INTO persons p VALUES mgr
  9         RETURNING REF(p) INTO m_ref   ;
10     INSERT INTO persons p VALUES app
11         RETURNING REF(p) INTO a_ref   ;
12     insert into interviews
13     values (interview_t(1001, sysdate, 45, 5, TREAT(a_ref AS REF manager_t)
         , TREAT(m_ref AS REF applicant_t)));
14  end;
15  /
PL/SQL procedure successfully completed.
SQL>
SQL> SELECT i.interviewno, i.is_made_by.surname, i.attended_by.surname
  2  FROM interviews i
  3  /
INTERVIEWNO IS_MADE_BY.SURNAME             ATTENDED_BY.SURNAME                 
       1001                                                                    
SQL> Kind of, but it's not very satisfactory. Let's use separate tables for MANAGERS and APPLICANTS...
SQL> rollback
  2  /
Rollback complete.
SQL>
SQL> CREATE TABLE managers OF manager_t
  2  /
Table created.
SQL>
SQL> CREATE TABLE applicants OF applicant_t
  2  /
Table created.
SQL> declare
  2     mgr manager_t := manager_t(1,'RUNCITER', 'GLEN', sysdate - (42*365), 'x1234');
  3     app applicant_t := applicant_t(2,  'CHIP', 'JOE', sysdate - (38*365), 'BSc, MSc');
  4     intv interview_t;
  5     m_ref REF  manager_t;
  6     a_ref REF applicant_t;
  7  begin
  8     INSERT INTO managers m VALUES mgr
  9         RETURNING REF(m) INTO m_ref   ;
10     INSERT INTO applicants a VALUES app
11         RETURNING REF(a) INTO a_ref   ;
12     insert into interviews values (interview_t(1001, sysdate, 45, 5, m_ref, a_ref));
13 
14  end;
15  /
PL/SQL procedure successfully completed.
SQL>
SQL> SELECT i.interviewno, i.is_made_by.surname, i.attended_by.surname
  2  FROM interviews i
  3  /
INTERVIEWNO IS_MADE_BY.SURNAME             ATTENDED_BY.SURNAME                 
       1001 RUNCITER                       CHIP                                
SQL> rollback
  2  /
Rollback complete.
SQL> declare
  2     mgr manager_t := manager_t(1,'RUNCITER', 'GLEN', sysdate - (42*365), 'x1234');
  3     app applicant_t := applicant_t(2,  'CHIP', 'JOE', sysdate - (38*365), 'BSc, MSc');
  4     intv interview_t;
  5     m_ref REF  manager_t;
  6     a_ref REF applicant_t;
  7  begin
  8     INSERT INTO managers m VALUES mgr
  9         RETURNING REF(m) INTO m_ref   ;
10     INSERT INTO applicants a VALUES app
11         RETURNING REF(a) INTO a_ref   ;
12     insert into interviews values (interview_t(1001, sysdate, 45, 5, a_ref, m_ref));
13 
14  end;
15  /
   insert into interviews values (interview_t(1001, sysdate, 45, 5, a_ref, m_ref));
ERROR at line 12:
ORA-06550: line 12, column 69:
PL/SQL: ORA-00932: inconsistent datatypes: expected REF APC.APPLICANT_T got REF
APC.MANAGER_T
ORA-06550: line 12, column 4:
PL/SQL: SQL Statement ignored
SQL>I hope that's useful to you.
Cheers, APC
Layout of SQL*Plus session tweaked for readability
Message was edited by:
APC

Similar Messages

  • Printing out results in case of object-relational table (Oracle)

    I have made a table with this structure:
    CREATE OR REPLACE TYPE Boat AS OBJECT(
    Name varchar2(30),
    Ident number,
    CREATE OR REPLACE TYPE Type_boats AS TABLE OF Boat;
    CREATE TABLE HOUSE(
    Name varchar2(40),
    MB Type_boats)
    NESTED TABLE MB store as P_Boat;
    INSERT INTO House VALUES ('Name',Type_boats(Boat('Boat1', 1)));
    I am using java to print out all the results by calling a procedure.
    CREATE OR REPLACE package House_boats
    PROCEDURE add(everything works here)
    PROCEDURE results_view;
    END House_boats;
    CREATE OR REPLACE Package.body House_boats AS
    PROCEDURE add(everything works here) AS LANGUAGE JAVA
    Name House_boats.add(...)
    PROCEDURE results_view AS LANGUAGE JAVA
    Name House_boats.resuts_view();
    END House_boats;
    However, I am not able to get Results.view working in case of object-relation table. This is how I do it in the situation of relational table.
    CALL House_boats.results_view();
    House_boats.java file which is loaded using LOADJAVA:
    import java.sql.*;
    import java io.*;
    public class House_boats {
    public static void results_view ()
       throws SQLException
       { String sql =
       "SELECT * from House";
       try { Connection conn = DriverManager.getConnection
    ("jdbc:default:connection:");
       PreparedStatement pstmt = conn.prepareStatement(sql);
       ResultSet rset = pstmt.executeQuery();
      printResults(rset);
      rset.close();
      pstmt.close();
       catch (SQLException e) {System.err.println(e.getMessage());
    static void printResults (ResultSet rset)
       throws SQLException { String buffer = "";
       try { ResultSetMetaData meta = rset.getMetaData();
       int cols = meta.getColumnCount(), rows = 0;
       for (int i = 1; i <= cols; i++)
       int size = meta.getPrecision(i);
       String label = meta.getColumnLabel(i);
       if (label.length() > size) size = label.length();
       while (label.length() < size) label += " ";
      buffer = buffer + label + " "; }
      buffer = buffer + "\n";
       while (rset.next()) {
      rows++;
       for (int i = 1; i <= cols; i++) {
       int size = meta.getPrecision(i);
       String label = meta.getColumnLabel(i);
       String value = rset.getString(i);
       if (label.length() > size) size = label.length();
       while (value.length() < size) value += " ";
      buffer = buffer + value + " ";  }
      buffer = buffer + "\n";   }
       if (rows == 0) buffer = "No data found!\n";
       System.out.println(buffer); }
       catch (SQLException e) {System.err.println(e.getMessage());}  }
    How do I print out the results correctly in my case of situation?
    Thank you in advance

    I have made a table with this structure:
    I am using java to print out all the results by calling a procedure.
    However, I am not able to get Results.view working in case of object-relation table. This is how I do it in the situation of relational table.
    How do I print out the results correctly in my case of situation?
    There are several things wrong with your code and methodology
    1. The code you posted won't even compile because there are several syntax issues.
    2. You are trying to use/test Java in the database BEFORE you get the code working outside the DB
    3. Your code is not using collections in JDBC properly
    I suggest that you use a different, proven approach to developing Java code for use in the DB
    1. Use SIMPLE examples and then build on them. In this case that means don't add collections to the example until ALL other aspects of the app work properly.
    2. Create and test the Java code OUTSIDE of the database. It is MUCH easier to work outside the database and there are many more tools to help you (e.g. NetBeans, debuggers, DBMS_OUTPUT windows, etc). Trying to debug Java code after you have already loaded it into the DB is too difficult. I'm not aware of anyone, even at the expert level, that develops that way.
    3. When using complex functionality like collections first read the Oracle documentation (JDBC Developer Guide and Java Developer's Guide). Those docs have examples that are known to work.
    http://docs.oracle.com/cd/B28359_01/java.111/b31225/chfive.htm
    http://docs.oracle.com/cd/E11882_01/java.112/e16548/oraarr.htm#sthref583
    The main issue with your example is #3 above; you are not using collections properly:
    String value = rset.getString(i);
    A collection is NOT a string so why would you expect that to work for a nested table?
    A collection needs to be treated like a collection. You can even treat the collection as a separate result set. Create your code outside the database and use the debugger in NetBeans (or other) on this replacement code for your 'printResults' method:
    static void printResults (ResultSet rset) throws SQLException {
        try {
           ResultSetMetaData meta = rset.getMetaData();
           while (rset.next()) {
               ResultSet rs = rset.getArray(2).getResultSet();
               rs.next();
               String ndx = rs.getString(1);
               Struct struct = (Struct) rs.getObject(2);
               System.out.println(struct.getSQLTypeName());
               Object [] oa = struct.getAttributes();
               for (int j = 0; j < oa.length; j++) {
                  System.out.println(oa[j]);
        } catch  (SQLException e) {
           System.err.println(e.getMessage());
    That code ONLY deals with column 2 which is the nested table. It gets that collection as a new resultset ('rs'). Then it gets the contents of that nested table as an array of objects and prints out the attributes of those objects so you can see them.
    Step through the above code in a debugger so you can SEE what is happening. NetBeans also lets you enter expressions such as 'rs' in an evaluation window so you can dynamically try the different methods to see what they do for you.
    Until you get you code working outside the database don't even bother trying to load it into the DB and create a Java stored procedure.
    Since your current issue has nothing to do with this forum I suggest that you mark this thread ANSWERED and repost it in the JDBC forum if you need further help with this issue.
    https://forums.oracle.com/community/developer/english/java/database_connectivity
    When you repost you can include a link to this current thread if you want. Once your Java code is actually working then try the Java Stored procedure examples in the Java Developer's Guide doc linked above.
    At the point you have any issues that relate to Java stored procedures then you should post them in the SQL and PL/SQL forum
    https://forums.oracle.com/community/developer/english/oracle_database/sql_and_pl_sql

  • MULTIPLE ROWS IN OBJECT RELATIONAL TABLE, HELP

    Hi,
    Here is my problem explanation. Please help. I have created an object type address, and a relational table called employee. One of the column in employee table is based on the type address. Now suppose I want to have 5 differrent addresses for a perticular employee how can I have it stored? The empno is the primary key .Here is the data strucure
    address( line1 varchar2(30),city varchar2(30), state varchar2(20), zip varchar2(13))
    employee
    (empno number,
    name varchar2(60),
    emp_add address)
    Thanks
    Feroz

    Well you could give your employees a nested table of addresses. But as William said, you really ought to use relational tables for this situation.
    I haven't yet come across a compelling argument for using Types instead of tables for data storage, and there are lots of drawbacks. Duplication of data is just one.
    Cheers, APC

  • Help with httpService returnFormat "object"

    Problem:
    My flex httpservice returns an xml file in the "object"
    resultFormat.
    How could I get the count of all childNodes of an object in
    that returned object tree.
    For example, in the xml file below:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <reporting>
    <series>
    <title>Edge Page Views, in Page Views per
    Second</title>
    <xLabel>startdatetime</xLabel>
    <y1Label>sum(pageviews)</y1Label>
    <data>
    <x>1216233600</x>
    <y1>79.605</y1>
    </data>
    <data>
    <x>1216233900</x>
    <y1>78.076</y1>
    </data>
    </series>
    <series>
    <title>Total Bandwidth, in Mbits per
    Second</title>
    <xLabel>startdatetime</xLabel>
    <y1Label>sum(egress_bytes_mbps)</y1Label>
    <y2Label>combined_midgress_bytes_mbps</y2Label>
    <y3Label>ovh_bytes_mbps</y3Label>
    <y4Label>sum(ingress_bytes_mbps)</y4Label>
    <data>
    <x>1216233600</x>
    <y1>36.160352</y1>
    <y2>66.48362700000001</y2>
    <y3>66.48362700000001</y3>
    <y4>96.01235200000002</y4>
    </data>
    <data>
    <x>1216233900</x>
    <y1>34.260794</y1>
    <y2>62.10649799999999</y2>
    <y3>62.10649799999999</y3>
    <y4>88.902323</y4>
    </data>
    <data>
    <x>1216234200</x>
    <y1>35.329617</y1>
    <y2>62.77339099999999</y2>
    <y3>62.77339099999999</y3>
    <y4>89.30751</y4>
    </data>
    </series>
    </reporting>
    The first series element has 4 children
    I am able to get the number of data elements as:
    "resultObj.reporting.series[0].data.length"
    How do I effectively retreive:
    "resultObj.reporting.series[0].childNodes().length"
    Apparently this does'nt work, I also tried Nodes, children().
    Any documentation or help with this would be awesome
    Thanks a ton
    Pranay

    Can someone please help me understand this error maybe?
    I would appreciate it
    [MessagingError message='Destination 'the destination of an
    xml file' either does not exist or the destination has no channels
    defined (and the application does not define any default
    channels.)']
    what are channels?

  • Need help with saving data and keeping table history for one BP

    Hi all
    I need help with this one ,
    Scenario:
    When adding a new vendor on the system the vendor is suppose to have a tax clearance certificate and it has an expiry date, so after the certificate has expired a new one is submitted by the vendor.
    So i need to know how to have SBO fullfil this requirement ?
    Hope it's clear .
    Thanks
    Bongani

    Hi
    I don't have a problem with the query that I know I've got to write , the problem is saving the tax clearance certificate and along side it , its the expiry date.
    I'm using South African localization.
    Thanks

  • Help with this cool function: =SUMIF(Table 1::$Month, COLUMN()−1, $Cost)

    Hello,
    I am a novice with respect to spreadsheet functions and needed a a cashflow spreadsheet.  I found this one (Download Cashflow Tracker for Numbers (iWork 09).) which is perfect but the author, I suspect, has not updated his website in years.  I attempted contacting him and received no reply.
    I receive an error with the following function:
    =SUMIF(Table 1::$Month, COLUMN()−1, $Cost)
    This occurs when I enter a date in the expense or income table.  Entering the date is required to make the spreadsheet work but when I do I receive an error that a number is expected when a date is entered.
    Can anyone give me some advice?  I would really like to use this spreadsheet.
    Thanks!
    Steve

    What I have found the simplest approach has been:
    1. Cut the Summary by Category table and paste it into the Transaction sheet, giving something like this (after rearranging renaming, etc, as desired):
    2. Make sure the links between the two table are still working, make their appearance the way you like, then duplicate that sheet for the other months.  Each sheet will then have its separate set of two interconnected tables.
    3. Copy paste one of the Summary tables back to the Summary sheet, rename it as desired, and set it up with formulas referencing the tables in the monthly sheets you have set up, something like this:
    If you want your summary by month you would set up 12 columns in the main 'Summary by Category' table, with each column referencing a different sheet.  Your Budget could be a row above each Actual figure, if you like, with difference in a row below that.
    This approach keeps the formulas simple and avoids having to set up fancy SUMIFS extracting data for each month from one big Transaction table.
    SG

  • Help with exp schema and related objects

    I need to export a schema from one database to another. I must also be able to export the tablespaces, roles, constraints, etc that are associated with it that aren't necessarily part of the schema. Is there an easy way to do this? I had already tried simply doing a schema exp/imp and it threw up a bunch of errors mostly grants which isn't that big of a deal but some of the tables were not created due to tablespaces being missing.

    exp system/manager file=exp.dmp log=exp.log full=y at the source database.
    imp system/manager file=exp.dmp log=imp_show.log full=y show=y - create the log file without importing the data
    edit the imp_show.log and extract the statements that are needed to re-create users,roles,alter user and grants.
    Pre-create the tablespaces using SQL*Plus in the target database.
    execute the modified imp_show.log(All DDl's)
    imp system/manager file=exp.dmp log=imp.log fromuser=A touser=B
    Re-compile all the Invalid Objects.
    HTH
    -Anantha

  • Help with Reading values from static table in a .pdf file

    Hi guys,
    Pls try to clear this doubt of mine.
    I basically have 2 files. Both are .pdf extension and they have tables in them. I need to compare certain values in one file with the corresponding values in the other table in the second file.
    I need to do this programatically in c# . net
    I have tried using packages like pdfbox and stuff which convert the pdf file into text. But cant I get the table as an object or something using which I can access the required rows and columns?
    Also, these tables are static information. They are not a part of a form or anything like that.
    Please help me with this.
    Thanks.

    The document is corrupt. Try a backup.

  • Error while working with POP-IN object for Table UI

    Hi Expert,
    I am creating a pop-in for one column of table UI. I have a LinkToAction object to open pop-in. i have some lable and input fields in pop-in. I dont know the flow to display the pop-in and where should i assign data to pop-in fields. how system will know which row i am clicking? Please help to know all details. I have a lots of questions.
    I am able to create link on the column and when i am clicking on link i am getting below error.
    "Node VIEW_VAL.1.POP_IN does not contain any elements" but i have attributes in node POP-_N.
    Please help me.
    Thanks and Regards,
    Anil
    Details from ST22----
    An exception occurred which is explained in detail below.
    The exception, which is assigned to class 'CX_WDR_ADAPTER_EXCEPTION', was not
    caught and
    therefore caused a runtime error.
    The reason for the exception is:
    Adapterfehler im  INPUT_FIELD "INPUT_FIELD01" des Views
    "Z_BP_GENERAL.VIEW_VAL": Context-Bindung des Properties VALUE kann nicht
    aufgelöst werden: Node VIEW_VAL.1.POP_IN does not contain any elements
    The occurrence of the exception is closely related to the occurrence of
    a previous exception "CX_WD_CONTEXT", which was raised in the program
    "CL_WDR_CONTEXT_NODE===========CP",
    specifically in line 9 of the (include) program
    "CL_WDR_CONTEXT_NODE===========CM00R".
    The cause of the exception was:
    Node VIEW_VAL.1.POP_IN does not contain any elements

    hi,
    Use this code in OnAction of LinktoAction UI element.
    This code will give you index of the row from which Link to Action is Triggered.
    <cn_popin> is my node binded to Table.
    data: lr_element type ref to if_wd_context_element.
    DATA ls_cn_popin TYPE wd_this->element_cn_popin.
    lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
    get all declared attributes
      lr_element->get_static_attributes(
        IMPORTING
          static_attributes = ls_cn_popin ).
    data lv type I.
    lv = lr_element->GET_INDEX( ).
    Finally you have the index in varialbe lv.

  • Querying XML data in  Object Relational tables

    Hi,
    Can someone help me?
    I have registered the purchaseorder.xsd in my database schema.
    [ http://www.oracle.com/technology/oramag/oracle/03-jul/o43xml.html ]
    declare
    l_bfile bfile;
    begin
    l_bfile := bfilename(
    'XMLSAMP', 'purchaseOrder.xsd');
    dbms_lob.open(l_bfile);
    dbms_xmlschema.registerschema('http://localhost:8080/purchaseOrder.xsd', l_bfile);
    dbms_lob.close(l_bfile);
    end;
    This has created a table "PURCHASEORDER"
    SYS_NC_ROWINFO$ SYS.XMLTYPE
    It has also created object types.
    select object_name from user_objects where object_type = 'TYPE' and object_name like 'XDBPO%'
    XDBPO_ACTIONS_TYPE
    XDBPO_ACTION_COLLECTION
    XDBPO_ACTION_TYPE
    XDBPO_LINEITEMS_TYPE
    XDBPO_LINEITEM_TYPE
    XDBPO_PART_TYPE
    XDBPO_REJECTION_TYPE
    XDBPO_SHIPINSTRUCTIONS_TYPE
    XDBPO_TYPE
    I have also inserted an xml into that table.
    INSERT INTO "PURCHASEORDER"
    VALUES
    xmltype
    getFileContent('ADAMS-20011127121040988PST.xml','XMLSAMP')
    Now how do I retrieve the data from this table and the other object types?
    Is extractvalue the only method? I have gone thru examples in the net but everything uses the element names in xml document and not the object type names.
    For example to retreive the lineitem details, this query can be used
    SELECT extractValue(value(d),'/Description')
    FROM "PURCHASEORDER" p,
    table (xmlsequence(extract(p.SYS_NC_ROWINFO$,'/PurchaseOrder/LineItems/LineItem/Description'))) d
    But I want to retreive it from "XDBPO_LINEITEM_TYPE".
    Is this possible?
    Can someone help me please?
    Thanks in advance.
    Jay

    #1. If you had taken the time to read some of the other posts in the forum all of the answers you needed were all there..
    #2. As PM's we are not expected to spend a lot of time dealing with the forums. In general we are expected only to step in and answer the questions that are not easily answered by carefully reading existing posts or deal with cases were the wrong answer is supplied.
    #3. I'm technically on vacation, and posted to that effect last week, so pushing for an answer is not at all appreciated...
    #4. The problem is extremely simple, at least as stated in your simple example.
    Given the schema.. Note It's been annotated
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
         <xs:element name="Bill">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="InvCtlN"/>
                        <xs:element ref="MedBU"/>
                        <xs:element ref="Lineitem" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="InvCtlN">
              <xs:simpleType>
                   <xs:restriction base="xs:byte">
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <xs:element name="LineCode">
              <xs:simpleType>
                   <xs:restriction base="xs:int">
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <xs:element name="Lineitem">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="Type"/>
                        <xs:element ref="LineCode"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="MedBU">
              <xs:simpleType>
                   <xs:restriction base="xs:string">
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <xs:element name="SampleFile" xdb:defaultTable="SAMPLE_FILE_TABLE">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="Bill" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="Type">
              <xs:simpleType>
                   <xs:restriction base="xs:string">
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
    </xs:schema>and the following instance
    <SampleFile xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="testcase.xsd">
         <Bill>
              <InvCtlN>1</InvCtlN>
              <MedBU>ABC</MedBU>
              <Lineitem>
                   <Type>P1</Type>
                   <LineCode>99214</LineCode>
              </Lineitem>
         </Bill>
         <Bill>
              <InvCtlN>2</InvCtlN>
              <MedBU>DEF</MedBU>
              <Lineitem>
                   <Type>P2</Type>
                   <LineCode>99215</LineCode>
              </Lineitem>
              <Lineitem>
                   <Type>P3</Type>
                   <LineCode>99216</LineCode>
              </Lineitem>
         </Bill>
         <Bill>
              <InvCtlN>3</InvCtlN>
              <MedBU>HJK</MedBU>
              <Lineitem>
                   <Type>P4</Type>
                   <LineCode>99217</LineCode>
              </Lineitem>
         </Bill>
    </SampleFile>The following appears to be what you are looking for
    SQL*Plus: Release 10.2.0.2.0 - Production on Mon Feb 20 22:42:53 2006
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    SQL> spool registerSchema_&4..log
    SQL> set trimspool on
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> declare
      2    result boolean;
      3  begin
      4    result := dbms_xdb.createResource('/home/&1/xsd/&4',
      5                                      bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
      6  end;
      7  /
    old   4:   result := dbms_xdb.createResource('/home/&1/xsd/&4',
    new   4:   result := dbms_xdb.createResource('/home/OTNTEST/xsd/testcase.xsd',
    old   5:                                    bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
    new   5:                                    bfilename(USER,'testcase.xsd'),nls_charset_id('AL32UTF8'));
    PL/SQL procedure successfully completed.
    SQL> commit
      2  /
    Commit complete.
    SQL> alter session set events='31098 trace name context forever'
      2  /
    Session altered.
    SQL> begin
      2    dbms_xmlschema.registerSchema
      3    (
      4      schemaURL => '&3',
      5      schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
      6      local     => TRUE,
      7      genTypes  => TRUE,
      8      genBean   => FALSE,
      9      genTables => &5
    10    );
    11  end;
    12  /
    old   4:     schemaURL => '&3',
    new   4:     schemaURL => 'testcase.xsd',
    old   5:     schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
    new   5:     schemaDoc => xdbURIType('/home/OTNTEST/xsd/testcase.xsd').getClob(),
    old   9:     genTables => &5
    new   9:     genTables => TRUE
    PL/SQL procedure successfully completed.
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.2.0 - Production on Mon Feb 20 22:42:55 2006
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    SQL> spool insertFile_&3..log
    SQL> set trimspool on
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> set timing on
    SQL> set long 10000
    SQL> --
    SQL> insert into &4 values (xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
      2  /
    old   1: insert into &4 values (xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
    new   1: insert into SAMPLE_FILE_TABLE values (xmltype(bfilename(USER,'testcase.xml'),nls_charset_id('AL32UTF8')
    1 row created.
    Elapsed: 00:00:00.06
    SQL> commit
      2  /
    Commit complete.
    Elapsed: 00:00:00.00
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.2.0 - Production on Mon Feb 20 22:42:55 2006
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    SQL> spool testcase.log
    SQL> --
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> --
    SQL> -- Testcase code here
    SQL> --
    SQL> set trimspool on
    SQL> set autotrace on explain
    SQL> set timing on
    SQL> set pages 10 lines 160 long 100000
    SQL> --
    SQL> column INVCTLN format  9999
    SQL> column MEDBU   format  A10
    SQL> column TYPE    format  A10
    SQL> column LINECODE format 999999999
    SQL> create or replace view MASTER_TABLE_VIEW
      2  (
      3     INVCTLN,
      4     MEDBU
      5  )
      6  as
      7  select extractValue(value(bill),'/Bill/InvCtlN'),
      8         extractValue(value(bill),'/Bill/MedBU')
      9    from SAMPLE_FILE_TABLE t,
    10         table(xmlsequence(extract(value(t),'/SampleFile/Bill'))) Bill
    11  /
    View created.
    Elapsed: 00:00:00.04
    SQL> create or replace view DETAIL_TABLE_VIEW
      2  (
      3     INVCTLN,
      4     TYPE,
      5     LINECODE
      6  )
      7  as
      8  select extractValue(value(bill),'/Bill/InvCtlN'),
      9         extractValue(value(LineItem),'/Lineitem/Type'),
    10         extractValue(value(LineItem),'/Lineitem/LineCode')
    11    from SAMPLE_FILE_TABLE t,
    12         table(xmlsequence(extract(value(t),'/SampleFile/Bill'))) Bill,
    13         table(xmlsequence(extract(value(bill),'/Bill/Lineitem'))) LineItem
    14  /
    View created.
    Elapsed: 00:00:00.05
    SQL> set autotrace on explain
    SQL> --
    SQL> select * from MASTER_TABLE_VIEW
      2  /
    INVCTLN MEDBU
          1 ABC
          2 DEF
          3 HJK
    Elapsed: 00:00:00.05
    Execution Plan
    Plan hash value: 2362844891
    | Id  | Operation          | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |                    |     3 |  6165 |   805   (1)| 00:00:10 |
    |   1 |  NESTED LOOPS      |                    |     3 |  6165 |   805   (1)| 00:00:10 |
    |*  2 |   TABLE ACCESS FULL| SAMPLE_FILE_TABLE  |     1 |    30 |     3   (0)| 00:00:01 |
    |*  3 |   INDEX RANGE SCAN | SYS_IOT_TOP_159053 |     3 |  6075 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
                  xmlns="http://xmlns.oracle.com/xdb/acl.xsd"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
                  http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><rea
                  d-properties/><read-contents/></privilege>'))=1)
       3 - access("NESTED_TABLE_ID"="SAMPLE_FILE_TABLE"."SYS_NC0000800009$")
    Note
       - dynamic sampling used for this statement
    SQL> select * from DETAIL_TABLE_VIEW
      2  /
    INVCTLN TYPE         LINECODE
          1 P1              99214
          3 P4              99217
          2 P2              99215
          2 P3              99216
    Elapsed: 00:00:00.07
    Execution Plan
    Plan hash value: 971642473
    | Id  | Operation               | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT        |                    |     4 |  8352 |   813   (0)| 00:00:10 |
    |   1 |  NESTED LOOPS           |                    |     4 |  8352 |   813   (0)| 00:00:10 |
    |   2 |   MERGE JOIN CARTESIAN  |                    |     4 |  8220 |   805   (0)| 00:00:10 |
    |*  3 |    TABLE ACCESS FULL    | SAMPLE_FILE_TABLE  |     1 |    30 |     3   (0)| 00:00:01 |
    |   4 |    BUFFER SORT          |                    |     4 |  8100 |   802   (0)| 00:00:10 |
    |   5 |     INDEX FAST FULL SCAN| SYS_IOT_TOP_159055 |     4 |  8100 |   802   (0)| 00:00:10 |
    |*  6 |   INDEX UNIQUE SCAN     | SYS_IOT_TOP_159053 |     1 |    33 |     2   (0)| 00:00:01 |
    |*  7 |    INDEX RANGE SCAN     | SYS_C0022871       |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
                  xmlns="http://xmlns.oracle.com/xdb/acl.xsd"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
                  http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-pro
                  perties/><read-contents/></privilege>'))=1)
       6 - access("NESTED_TABLE_ID"="SYS_NTh/v83GzKQ1evte63P5QRog=="."SYS_NC0000700008$")
           filter("NESTED_TABLE_ID"="SAMPLE_FILE_TABLE"."SYS_NC0000800009$")
       7 - access("NESTED_TABLE_ID"="SYS_NTh/v83GzKQ1evte63P5QRog=="."SYS_NC0000700008$")
    Note
       - dynamic sampling used for this statement
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    C:\xdb\otn\362337>

  • Need help with disappearing header row in tables

    Hey guys.
    I'm working on a large document with tables (annual report). I have set up table styles with header and body cell styles. When I apply the table style to a table, then convert the first row to header row, the entire header row disappears...!
    If I leave the row as body row and just apply the header cell style to it, it won't disappear. The row will only disappear if I convert it to header row in Indesign.
    I checked the Word doc I imported the text from, the first row of the tables is just normal body row.
    I dunno where to look so I have no idea how to fix this problem. It happens to all the tables. I was supplied this file. I don't particularly want to recreate the file. The original file was created in Creative Clouds and exported to idml for me as I have CS6.
    Has anyone experienced the same problem or know what's the solution? I really need help.
    Thanks in advance.

    It may be on the Table Options dailog box on the section of Headers and Footers> Header: Repeat Header the Skip First is check on.

  • Help with listing records from two tables

    Hi: I have two tables joined by the first field. The field is primary key in first table. Need help listing records from both tables with each record one line/record.
    create table EVENTS (
    event_key varchar2(64) primary key,
    event_description varchar2(64),
    create_time int
    create table EVENT_UPDATES (
    event_key varchar2(64) NOT NULL ,
    update_description varchar2(64),
    update_time int
    insert into EVENTS values('Event1', 'This is event1', 1);
    insert into EVENT_UPDATES values('Event1', 'Ticket created', 3);
    insert into EVENT_UPDATES values('Event1', 'Event cleared', 10);
    insert into EVENTS values('Event2', 'This is event2', 4);
    insert into EVENT_UPDATES values('Event2', 'Ticket created', 6);
    insert into EVENT_UPDATES values('Event2', 'Event cleared', 8);I want to print each record in EVENTS table as one line and corresponding records in EVENT_UPDATES as one line/record like this
    Event1   1     This is event1
                3     Ticket created
                10   Event cleared
    Event2   4     This is event2
                6     Ticket created
                8     Event clearedTIA
    Ravi

    select  case weight
              when 1 then event_key
            end key,
            time_val,
            description
      from  (
              select  event_key,
                      create_time time_val,
                      event_description description,
                      1 weight
                from  events
             union all
              select  event_key,
                      update_time,
                      update_description,
                      2 weight
                from  event_updates
      order by event_key,
               weight
    KEY          TIME_VAL DESCRIPTION
    Event1              1 This is event1
                        3 Ticket created
                       10 Event cleared
    Event2              4 This is event2
                        6 Ticket created
                        8 Event cleared
    6 rows selected.
    SQL> SY.

  • Help with setting primary key in table

    Hi,
    I have created a table in Oracle and populated it with information, but I need a primary key (like an autonumber in Access) to identify each record. How can I do this for an existing table?
    Thanks so much for any help you can provide!

    Hello,
    I am assuming you have created the sequence and trigger i posted in my earlier post, here run this and if this answers your question mark post answered and reward points for helpful posts.
    INSERT INTO customer1 (FIRST_NAME,
                           LAST_NAME,
                           TITLE,
                           ADDRESS1,
                           ADDRESS2,
                           CITY,
                           STATE,
                           ZIP,
                           PHONE,
                           EXTENSION,
                           FAX,
                           WORK_PHONE,
                           WORK_EXTENSION,
                           MOBILE_PHONE,
                           EMERGENCY_PHONE,
                           PHONE_NOTES,
                           EMAIL)
       SELECT   FIRST_NAME,
                LAST_NAME,
                TITLE,
                ADDRESS1,
                ADDRESS2,
                CITY,
                STATE,
                ZIP,
                PHONE,
                EXTENSION,
                FAX,
                WORK_PHONE,
                WORK_EXTENSION,
                MOBILE_PHONE,
                EMERGENCY_PHONE,
                PHONE_NOTES,
                EMAIL
         FROM   CUSTOMER;
         COMMIT;Regards

  • I need help with a trigger mutating a table

    I'll add the trigger I have written now at the bottom. Here is the problem that I have. We have employees and their families in an individual table.
    A family is indicated by matching client, branch, and emp_id. An employee is indicated by individual_num = 1. All other numbers indicate family members. A person is determined to be terminated by having a date other than '2299/12/31' (It's a varchar(10) and very very wrong. Don't ask...) in the termination date column.
    A family member can be terminated in the system independent of the rest of there family. However, if an employee is terminated then all active family members need the termination date set to the same date as the employee. If that termination date is then changed for the employee all family members with the same date need to have their dates updated.
    I understand why this causes table mutation but I need a work around. Any ideas? Please...
    CREATE OR REPLACE TRIGGER INDIV_EMP_TERM
    after update on INDIVIDUAL
    for each row
    begin
    if ( :new.INDIVIDUAL_NUM = 1 and :old.TERMINATION_DATE <> :new.TERMINATION_DATE ) then
    if ( :old.TERMINATION_DATE = '2299/12/31' ) then
         update INDIVIDUAL
              set TERMINATION_DATE = :new.TERMINATION_DATE
              where CLIENT = :new.CLIENT
              and BRANCH = :new.BRANCH
              and EMP_ID = :new.EMP_ID
              and INDIVIDUAL_NUM <> 1
              and TERMINATION_DATE = '2299/12/31';
         else
         update INDIVIDUAL
              set TERMINATION_DATE = :new.TERMINATION_DATE
              where CLIENT = :new.CLIENT
              and BRANCH = :new.BRANCH
              and EMP_ID = :new.EMP_ID
              and INDIVIDUAL_NUM <> 1
              and TERMINATION_DATE = :old.TERMINATION_DATE;
         end if;
    end if;
    end;

    Try your code like this below .It will help you to eliminate the mutating error
    create or replace PACKAGE test_update IS
    type row_type is table of rowid index by binary_integer;
    v_row row_type ;
    v_index binary_integer ;
    v_num integer := 0 ;
    flag integer := 1 ;
    END;
    create or replace trigger test_up
    before update
    on test123
    begin
    select USR_ID
    into test_update.v_num
    from test123 ;
    dbms_output.put_line ( 'before update '||test_update.v_num );
    test_update.v_index := 0;
    end ;
    create or replace trigger test_up_after
    after update
    on test123
    begin
    dbms_output.put_line ( test_update.v_index );
    test_update.flag := 0 ;
    for i in 1 .. test_update.v_index loop
    update test123
    set UPD_BY = nvl(test_update.v_num ,0),
    UPD_DATE = sysdate
    where rowid = test_update.v_row(i) ;
    end loop ;
    test_update.flag := 1 ;
    test_update.v_index := 0;
    end ;
    create or replace trigger test_1
    after update on test123
    for each row
    begin
    -- dbms_output.put_line ( 'after update test flag '||test_update.flag );
    if test_update.flag = 1 then
    test_update.v_index := test_update.v_index + 1 ;
    test_update.v_row(test_update.v_index) := :old.rowid ;
    end if ;
    end ;

  • Help with drop create and update table

    Sir/Madam,
    I have joined 5 tables and selected some columns ,then I need to update some columns in that. After updating I need to create a report with the new column values.
    To do this my method is to create temp table with the select statement then update the temp table , use this temp table for the report and then drop the temp table.
    Is there anyother way to do this ??
    Can I create a cursor and update the cursor column ??
    Does dynamic sql always be created as procedure ??

    Hi,
    you need to understand how eventing works in BSP and MVC architecture. Pls refer to the below link for a basic understanding of how BSP works - View, Controller and Model class concepts.
    http://www.sapdev.co.uk/webapps/bsp/washome.htm
    For your requirement -
    1. you need a view on which you will create a drop down list UI element and a table view element
    2. you will need to create a contoller class - this will be used to handle the event that will be triggered   when user selects an entry from drop down list
    3. you will need a model class in which you will write the business logic to retrieve employees of selected department.
    Pls search this forum or blogs for - data binding with BSPs, Table View. Pls read these concepts and try to develop your requirement. You can come back to this forum if you face any issues during development.
    hope this helps.

Maybe you are looking for

  • DLP Attachment Scanning - Size Limitations

    Is it documented anywhere what the attachment file size limitations are for DLP scanning?  In the ESA Configuration documentation I read: "To scan attachments, the content scanning engine extracts the attachment for the RSA Email DLP scanning engine

  • HT1349 icloud storage for multiple items

    I have just inherited my friends ipad, so now I have 2 ipads and my iphone. Icloud is still only giving my 5 GB...shouldnt it be 10 GB?

  • Where Can I find a re download of acrobat 9 pro for mac??

    Anyone know where i can get another copy of this??

  • Reading and Splitting

    I have 5 classes: Fruit Apple, Melon and gooseberry extends Fruit and has few additional attributes of their own FruitExpert is the main class I have to read from a file which is record based according to the first line. For Eg: APPLE CRISPIN YELLOWI

  • Old POs affected by release strategy change

    Hello, Recently major changes were made to a group of release strategies for our business. The new release strategies are being applied correctly to all new POs. However, even POs created before the change of release strategies are showing the new st