XSU insert into join view

I've looked through a lot of the discussions here, and seen the
same question I have:
How do you use XSU to insert XML into master-detail structure?
And the answer seems to be, "insert into a view".
Could you give me example SQL for the type of view you mean?
And how the XML might look?
(is it like...
<ROWSET>
<ROW>
<MASTER_KEY>KEYVALUE</MASTER_KEY>
<MASTER_ATTR>SOME MASTER ATTRIBUTE</MASTER_ATTR>
<MASTER_ATTR2>ANOTHER ATTRIBUTE</MASTER_ATTR2>
</ROW>
<ROW>
<DETAIL_FK>KEYVALUE</DETAIL_FK>
<DETAIL_ATTR>DETAIL ROW ATTRIBUTE</DETAIL_ATTR>
</ROW>
<ROW>
<DETAIL_FK>KEYVALUE</DETAIL_FK>
<DETAIL_ATTR>ANOTHER DETAIL ROW</DETAIL_ATTR>
</ROW>
</ROWSET>
null

I do not have TOAD, but I tried your posted example from PL/SQL Developer and it seems to work as expected. Can you post some more detail as to how you are doing it from TOAD and what the issue is, with errors, if any:
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as kkishore
SQL>
Table created
View created
Trigger created
1 row inserted
        F1
         1
         1
OWNER                          TABLE_NAME                     COLUMN_NAME                    UPDATABLE INSERTABLE DELETABLE
KKISHORE                       DUMMY_V                        F1                             NO        NO         NO
SQL>

Similar Messages

  • Inserting into XMLType View

    I have created an XMLType view with an INSTEAD OF trigger to insert data into the underlying tables. I used your example on XMLType view of Relational Content
    It works great if I have no attributes defined in the root element of the XML document (i.e. xmlns, schemaLocation, etc.). However, if my document contains any of those attributes, it will not load. I have tried creating the view with and without the xml attributes, as well as making sure that the schemaLocation is identical to the one in the document (copied and pasted just to make sure).
    Is there anything that you can point to right away that I'm missing?
    If needed, I can post code for you.
    Thanks!

    Here is the code I used to generate the tables, view, and triggers:
    drop table p_student_demographics;
    create table p_student_demographics -- a
    wiser_id varchar2(8),
    first_name varchar2(15),
    middle_name varchar2(15),
    last_name varchar2(25),
    birthdate date,
    school_id varchar2(7),
    special_ed_teacher varchar2(50)
    drop table p_scorer_info;
    create table p_scorer_info -- b
    test_record_id number,
    scorer_number number,
    name varchar2(80),
    email varchar2(50)
    drop table p_test_record;
    create table p_test_record -- c
    wiser_id varchar2(8),
    test_record_id number,
    grade_tested varchar2(2),
    first_scorer_completed varchar2(3),
    second_scorer_completed varchar2(3)
    drop table p_psw_test_results;
    create table p_psw_test_results -- d
    test_record_id number,
    subject varchar2(7),
    entry_number number,
    complexity varchar2(1),
    performance varchar2(1),
    independence varchar2(1),
    generalization varchar2(1),
    non_scorable varchar2(4)
    drop table p_spe_test_results;
    create table p_spe_test_results -- e
    test_record_id number,
    subject varchar2(7),
    entry_number number,
    item_number number,
    response varchar2(1)
    drop table p_total_scores;
    create table p_total_scores -- f
    test_record_id number,
    subject varchar2(7),
    psw_total_raw_score varchar2(2),
    spe_total_raw_score varchar2(2),
    tas_score varchar2(2),
    tas_portfolio_score varchar2(2),
    tas_spe_score varchar2(2),
    overall_total_raw_score varchar2(2),
    overall_performance_level varchar2(1)
    drop table p_school_info;
    create table p_school_info
    district_id varchar2(7),
    district_name varchar2(80),
    school_id varchar2(7),
    school_name varchar2(80)
    create or replace view paws_alt_test_results
    of xmltype
    xmlschema "http://www.k12.wy.us/public/paws-alt-results-v1.xsd" element "PawsAltResults"
    with object id
    (to_number(extractValue(object_value,'/PawsAltResults/Students/TestRecord/TestRecordId')))
    as
    select xmlelement
    "PawsAltResults",
    xmlelement
    "Students",
    xmlelement
    "StudentInfo",
    xmlelement
    "StudentDemographics",
    xmlelement("WiserId", a.wiser_id),
    xmlelement("FirstName", a.first_name),
    xmlelement("MiddleName", a.middle_name),
    xmlelement("LastName", a.last_name),
    xmlelement("BirthDate", a.birthdate)
    xmlelement("SchoolId", a.school_id),
    xmlelement("SpecialEdTeacher", a.special_ed_teacher),
    xmlelement
    "DocumentCompletedBy",
    xmlelement("FirstScorer", c.first_scorer_completed),
    xmlelement("SecondScorer", c.second_scorer_completed)
    xmlelement
    "FirstScorerInfo",
    xmlelement("Name", b1.name),
    xmlelement("Email", b1.email)
    xmlelement
    "SecondScorerInfo",
    xmlelement("Name", b2.name),
    xmlelement("Email", b2.email)
    xmlelement
    "TestRecord",
    xmlelement("TestRecordId", c.test_record_id),
    xmlelement("GradeTested", c.grade_tested),
    xmlelement
    "Subjects",
    select xmlagg
    xmlelement
    "Subject",
    xmlelement("SubjectName", f.subject),
    xmlelement
    "Psw",
    xmlelement
    "Entries",
    select xmlagg
    xmlelement
    "Entry",
    xmlelement("EntryNumber", x.entry_number),
    xmlelement("Complexity", x.complexity),
    xmlelement("Performance", x.performance),
    xmlelement("Independence", x.independence),
    xmlelement("Generalization", x.generalization),
    xmlelement("NonScorable", x.non_scorable)
    from p_psw_test_results x
    where f.test_record_id = x.test_record_id
    and f.subject = x.subject
    xmlelement("TotalRawScore", f.psw_total_raw_score)
    xmlelement
    "Spe",
    xmlelement
    "Entries",
    select xmlagg
    xmlelement
    "Entry",
    xmlelement("EntryNumber", x.entry_number),
    xmlelement
    "Items",
    select xmlagg
    xmlelement
    "Item",
    xmlelement("ItemNumber", y.item_number),
    xmlelement("Response", y.response)
    from p_spe_test_results y
    where x.test_record_id = y.test_record_id
    and x.subject = y.subject
    and x.entry_number = y.entry_number
    from (select distinct
    test_record_id,
    subject,
    entry_number
    from p_spe_test_results) x
    where f.test_record_id = x.test_record_id
    and f.subject = x.subject
    xmlelement("TotalRawScore", f.spe_total_raw_score)
    xmlelement("TasScore", f.tas_score),
    xmlelement("TasPortfolioScore", f.tas_portfolio_score),
    xmlelement("TasSpeScore", f.tas_spe_score),
    xmlelement("OverallTotalRawScore", f.overall_total_raw_score),
    xmlelement("OverallPerformanceLevel", f.overall_performance_level)
    from p_total_scores f
    where c.test_record_id = f.test_record_id
    xmlelement
    "Districts",
    select xmlagg
    xmlelement
    "DistrictInfo",
    xmlelement("DistrictId", district_id),
    xmlelement("DistrictName", district_name)
    from (select distinct
    district_id,
    district_name
    from p_school_info)
    xmlelement
    "Schools",
    select xmlagg
    xmlelement
    "SchoolInfo",
    xmlelement("DistrictId", district_id),
    xmlelement("SchoolId", school_id),
    xmlelement("SchoolName", school_name)
    from p_school_info
    from p_student_demographics a,
    p_scorer_info b1,
    p_scorer_info b2,
    p_test_record c
    where a.wiser_id = c.wiser_id
    and b1.test_record_id = b2.test_record_id
    and b1.test_record_id = c.test_record_id
    and b1.scorer_number = 1
    and b2.scorer_number = 2;
    create or replace trigger io_ins_paws_alt_results
    instead of insert on paws_alt_test_results
    begin
    insert all
    into p_student_demographics
    (wiser_id, first_name, middle_name, last_name, birthdate, school_id,
    special_ed_teacher)
    values
    (wiser_id, first_name, middle_name, last_name, birthdate, school_id,
    special_ed_teacher)
    into p_scorer_info
    (test_record_id, scorer_number, name, email)
    values
    (test_record_id, 1, name1, email1)
    into p_scorer_info
    (test_record_id, scorer_number, name, email)
    values
    (test_record_id, 2, name2, email2)
    into p_test_record
    (wiser_id, test_record_id, grade_tested, first_scorer_completed,
    second_scorer_completed)
    values
    (wiser_id, test_record_id, grade_tested, first_scorer_completed,
    second_scorer_completed)
    select a.*
    from xmltable
    '/PawsAltResults'
    passing :new.object_value
    columns
    wiser_id varchar2(8) path 'Students/StudentInfo/StudentDemographics/WiserId',
    first_name varchar2(15) path 'Students/StudentInfo/StudentDemographics/FirstName',
    middle_name varchar2(15) path 'Students/StudentInfo/StudentDemographics/MiddleName',
    last_name varchar2(25) path 'Students/StudentInfo/StudentDemographics/LastName',
    birthdate date path 'Students/StudentInfo/StudentDemographics/Birthdate',
    school_id varchar2(7) path 'Students/StudentInfo/SchoolId',
    special_ed_teacher varchar2(50) path 'Students/StudentInfo/SpecialEdTeacher',
    test_record_id number path 'Students/StudentInfo/TestRecord/TestRecordId',
    name1 varchar2(80) path 'Students/StudentInfo/FirstScorerInfo/Name',
    email1 varchar2(50) path 'Students/StudentInfo/FirstScorerInfo/Email',
    name2 varchar2(80) path 'Students/StudentInfo/SecondScorerInfo/Name',
    email2 varchar2(50) path 'Students/StudentInfo/SecondScorerInfo/Email',
    grade_tested varchar2(2) path 'Students/StudentInfo/TestRecord/GradeTested',
    first_scorer_completed varchar2(3) path 'Students/StudentInfo/DocumentCompletedBy/FirstScorer',
    second_scorer_completed varchar2(3) path 'Students/StudentInfo/DocumentCompletedBy/SecondScorer'
    ) a;
    insert all
    into p_psw_test_results
    (test_record_id, subject, entry_number, complexity, performance,
    independence, generalization, non_scorable)
    values
    (test_record_id, subject, entry_number, complexity, performance,
    independence, generalization, non_scorable)
    into p_total_scores
    (test_record_id, subject, psw_total_raw_score, spe_total_raw_score,
    tas_score, tas_portfolio_score, tas_spe_score,
    overall_total_raw_score, overall_performance_level)
    values
    (test_record_id, subject, psw_total_raw_score, spe_total_raw_score,
    tas_score, tas_portfolio_score, tas_spe_score,
    overall_total_raw_score, overall_performance_level)
    select a.test_record_id,
    b.subject,
    b.psw_total_raw_score,
    b.spe_total_raw_score,
    b.tas_score,
    b.tas_portfolio_score,
    b.tas_spe_score,
    b.overall_total_raw_score,
    b.overall_performance_level,
    c.*
    from xmltable
    '/PawsAltResults/Students/StudentInfo/TestRecord'
    passing :new.object_value
    columns
    test_record_id number path 'TestRecordId',
    subjects xmltype path 'Subjects/Subject'
    ) a,
    xmltable
    '/Subject'
    passing a.subjects
    columns
    subject varchar2(7) path 'SubjectName',
    psw_total_raw_score varchar2(2) path 'Psw/Entries/TotalRawScore',
    spe_total_raw_score varchar2(2) path 'Spe/TotalRawScore',
    tas_score varchar2(2) path 'TasScore',
    tas_portfolio_score varchar2(2) path 'TasPortfolioScore',
    tas_spe_score varchar2(2) path 'TasSpeScore',
    overall_total_raw_score varchar2(2) path 'OverallTotalRawScore',
    overall_performance_level varchar2(1) path 'OverallPerformanceLevel',
    entries xmltype path 'Psw/Entries/Entry'
    ) b,
    xmltable
    '/Entry'
    passing b.entries
    columns
    entry_number number path 'EntryNumber',
    complexity varchar2(1) path 'Complexity',
    performance varchar2(1) path 'Performance',
    independence varchar2(1) path 'Independence',
    generalization varchar2(1) path 'Generalization',
    non_scorable varchar2(4) path 'NonScorable'
    ) c;
    insert
    into p_spe_test_results
    (test_record_id, subject, entry_number, item_number, response)
    select a.test_record_id,
    b.subject,
    c.entry_number,
    d.*
    from xmltable
    '/PawsAltResults/Students/StudentInfo/TestRecord'
    passing :new.object_value
    columns
    test_record_id number path 'TestRecordId',
    subjects xmltype path 'Subjects/Subject'
    ) a,
    xmltable
    '/Subject'
    passing a.subjects
    columns
    subject varchar2(7) path 'SubjectName',
    entries xmltype path 'Spe/Entries/Entry'
    ) b,
    xmltable
    '/Entry'
    passing b.entries
    columns
    entry_number number path 'EntryNumber',
    items xmltype path 'Items/Item'
    ) c,
    xmltable
    '/Item'
    passing c.items
    columns
    item_number number path 'ItemNumber',
    response varchar2(1) path 'Response'
    ) d;
    insert
    into p_school_info
    (district_id, district_name, school_id, school_name)
    select a.district_id,
    a.district_name,
    b.school_id,
    b.school_name
    from xmltable
    'PawsAltResults/Districts/DistrictInfo'
    passing :new.object_value
    columns
    district_id varchar2(7) path 'DistrictId',
    district_name varchar2(80) path 'DistrictName'
    ) a,
    xmltable
    'PawsAltResults/Schools/SchoolInfo'
    passing :new.object_value
    columns
    district_id varchar2(7) path 'DistrictId',
    school_id varchar2(7) path 'SchoolId',
    school_name varchar2(80) path 'SchoolName'
    ) b
    where a.district_id = b.district_id;
    end io_ins_paws_alt_results;
    XML document:
    <?xml version="1.0" encoding="UTF-8"?>
    <PawsAltResults xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema http://www.k12.wy.us/public/paws-alt-results-v1.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
    <Students>
    <StudentInfo>
    <StudentDemographics>
    <WiserId>12345678</WiserId>
    <FirstName>TestFirst</FirstName>
    <MiddleName>M</MiddleName>
    <LastName>TestLast</LastName>
    <BirthDate>2000-02-02</BirthDate>
    </StudentDemographics>
    <SchoolId>2222222</SchoolId>
    <SpecialEdTeacher>Test Special Ed Teacher</SpecialEdTeacher>
    <DocumentCompletedBy>
    <FirstScorer>Yes</FirstScorer>
    <SecondScorer>No</SecondScorer>
    </DocumentCompletedBy>
    <FirstScorerInfo>
    <Name>Test First Scorer</Name>
    <Email>[email protected]</Email>
    </FirstScorerInfo>
    <SecondScorerInfo>
    <Name>Test Second Scorer</Name>
    <Email>[email protected]</Email>
    </SecondScorerInfo>
    <TestRecord>
    <TestRecordId>1</TestRecordId>
    <GradeTested>08</GradeTested>
    <Subjects>
    <Subject>
    <SubjectName>Reading</SubjectName>
    <Psw>
    <Entries>
    <Entry>
    <EntryNumber>1</EntryNumber>
    <Complexity>1</Complexity>
    <Performance>2</Performance>
    <Independence>3</Independence>
    <Generalization>B</Generalization>
    </Entry>
    </Entries>
    <TotalRawScore>20</TotalRawScore>
    </Psw>
    <Spe>
    <Entries>
    <Entry>
    <EntryNumber>1</EntryNumber>
    <Items>
    <Item>
    <ItemNumber>1</ItemNumber>
    <Response>1</Response>
    </Item>
    <Item>
    <ItemNumber>2</ItemNumber>
    <Response>2</Response>
    </Item>
    </Items>
    </Entry>
    </Entries>
    <TotalRawScore>30</TotalRawScore>
    </Spe>
    <TasScore>10</TasScore>
    <TasPortfolioScore>20</TasPortfolioScore>
    <TasSpeScore>15</TasSpeScore>
    <OverallTotalRawScore>50</OverallTotalRawScore>
    <OverallPerformanceLevel>3</OverallPerformanceLevel>
    </Subject>
    </Subjects>
    </TestRecord>
    </StudentInfo>
    </Students>
    <Districts>
    <DistrictInfo>
    <DistrictId>1111111</DistrictId>
    <DistrictName>Test District Name</DistrictName>
    </DistrictInfo>
    </Districts>
    <Schools>
    <SchoolInfo>
    <DistrictId>1111111</DistrictId>
    <SchoolId>2222222</SchoolId>
    <SchoolName>Test School Name</SchoolName>
    </SchoolInfo>
    </Schools>
    </PawsAltResults>
    Insert statement:
    insert into paws_alt_test_results values (xmltype(bfilename('XMLDIR','test-paws-alt.xml'),nls_charset_id('AL32UTF8')));
    There are no errors shown on the insert statement. It tells me that one row was inserted, but there is no data when looking at the tables (unless I remove the attributes from the root element of the XML file).
    I'm using version 10.2.0.3
    Thanks for your help!

  • Problem Inserting into object view with OracleXmlSave

    Gurus,
    I'm trying to insert into an object view with
    multiple collections of objects representing a master/detail relationship and a CLOB column, but I've this error:
    oracle.xml.sql.OracleXMLSQLException: Error Interno
    at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:1967)
    at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1060)
    at onix.interface_isbn.OnixXmlLoader.doInsert(OnixXmlLoader.java:165)
    at onix.interface_isbn.OnixXmlLoader.setLoader(OnixXmlLoader.java, Compiled Code)
    at onix.interface_isbn.OnixXmlLoader.<init>(OnixXmlLoader.java:23)
    at onix.interface_isbn.correrLoader.main(correrLoader.java:77)
    I'm using OracleXmlSave with insertXML method to do this.
    Is There any limitations to do that? (example
    number of tables into the view, columns datatype).
    I'd appreciate any comments
    Thank

    No known limitations. Please post the sample DDL to create your object types and object view, along with an example of the example XML document you're trying to insert.

  • How can I insert into a view cache???

    I have a problem in JClient like that:
    A form that have 3 JTable:
    - Table1 get data from UserTable in DB
    - Table2 get data from GroupTable in DB
    - Table3 get data from GroupTable in DB
    and 2 buttons: btnAdd, btnRemove.
    When I select a row in Table1, Table2 will get all records in GroupTable that row in Table1 belonging to and Table3 will get all records in GroupTable that row in Table1 not belonging to.
    I want that when I select some rows in Table3 and click btnAdd then those rows in Table3 will be insert into Table2 and remove those rows from Table3. And when I select some rows in Table2 and click btnRemove then those rows in Table2 will be insert into Table3 and remove those rows from Table2.
    Can you show me how to show that problem.
    Thanks.

    Hi,
    When do you get this error? Is it while running or while creating the form.
    Here is a sample code which inserts a non-database column dummy into a table called dummy. This is done in successful procedure.
    declare
    l_dummy varchar2(1000);
    begin
    l_dummy := p_session.get_value_as_varchar2(p_block_name=>'DEFAULT',
    p_attribute_name=>'A_DUMMY');
    insert into sjayaram903_1g.dummy values(l_dummy);commit;
    end;
    Please check in your case if the size of the local variable is enough to hold the values being returned.
    Thanks,
    Sharmila

  • BULK INSERT into View w/ Instead Of Trigger - DML ERROR LOGGING Issue

    Oracle 10.2.0.4
    I cannot figure out why I cannot get bulk insert errors to aggregate and allow the insert to continue when bulk inserting into a view with an Instead of Trigger. Whether I use LOG ERRORS clause or I use SQL%BULK_EXCEPTIONS, the insert works until it hits the first exception and then exits.
    Here's what I'm doing:
    1. I'm bulk inserting into a view with an Instead of Trigger on it that performs the actual updating on the underlying table. This table is a child table with a foreign key constraint to a reference table containing the primary key. In the Instead of Trigger, it attempts to insert a record into the child table and I get the following exception: +5:37:55 ORA-02291: integrity constraint (FK_TEST_TABLE) violated - parent key not found+, which is expected, but the error should be logged in the table and the rest of the inserts should complete. Instead the bulk insert exits.
    2. If I change this to bulk insert into the underlying table directly, it works, all errors get put into the error logging table and the insert completes all non-exception records.
    Here's the "test" procedure I created to test my scenario:
    View: V_TEST_TABLE
    Underlying Table: TEST_TABLE
    PROCEDURE BulkTest
    IS
    TYPE remDataType IS TABLE of v_TEST_TABLE%ROWTYPE INDEX BY BINARY_INTEGER;
    varRemData remDataType;
    begin
    select /*+ DRIVING_SITE(r)*/ *
    BULK COLLECT INTO varRemData
    from TEST_TABLE@REMOTE_LINK
    where effectiveday < to_date('06/16/2012 04','mm/dd/yyyy hh24')
    and terminationday > to_date('06/14/2012 04','mm/dd/yyyy hh24');
    BEGIN
    FORALL idx IN varRemData.FIRST .. varRemData.LAST
    INSERT INTO v_TEST_TABLE VALUES varRemData(idx) LOG ERRORS INTO dbcompare.ERR$_TEST_TABLE ('INSERT') REJECT LIMIT UNLIMITED;
    EXCEPTION WHEN others THEN
    DBMS_OUTPUT.put_line('ErrorCode: '||SQLCODE);
    END;
    COMMIT;
    end;
    I've reviewed Oracle's documentation on both DML logging tools and neither has any restrictions (at least that I can see) that would prevent this from working correctly.
    Any help would be appreciated....
    Thanks,
    Steve

    Thanks, obviously this is my first post, I'm desperate to figure out why this won't work....
    This code I sent is only a test proc to try and troubleshoot the issue, the others with the debug statement is only to capture the insert failing and not aggregating the errors, that won't be in the real proc.....
    Thanks,
    Steve

  • How to putXML on a joined View?

    Hi
    I would like to insert an XML document into two tables (some
    elements into table 1 and some into table 2). I have created a
    joined view of the two tables and have tried to insert into the
    view with:
    java OracleXML putXML -user %USER_PASSWORD% -filename myfile.xml
    myView
    But I get the error "cannot modify a column which maps to a non
    key-preserved table". PLEASE GIVE A SPECIFIC EXAMPLE OF AN
    UPDATABLE 'VIEW' WHERE AN INSERT CAN MODIFY MORE THAN ONE
    UNDERLYING TABLE. Is it possible?
    Any example will do. But here is what I tried to do. I tried
    to map the first few ROW child elements of an XML document (shown
    at the bottom) into columns of the EMP table and the remaining
    child
    elements into another table called RELATIVE (this is a table
    containing next-of-kin contact information for each employee). I
    created a RELATIVE table with:
    CREATE TABLE RELATIVE (
    IDREL NUMBER(15) PRIMARY KEY,
    EMPNUM NUMBER(4) CONSTRAINT FK_REL REFERENCES SCOTT.EMP(EMPNO),
    RNAME VARCHAR2(20) NOT NULL,
    TEL NUMBER(14),
    STREET VARCHAR2(30),
    CITY VARCHAR2(20),
    STATE VARCHAR2(10),
    ZIP VARCHAR2(12),
    COUNTRY VARCHAR2(20)
    I added a EMPNO_DUP column to the EMP table that is a copy of
    the
    EMPNO primary key (I did this so as to use EMPNO_DUP for the two
    table join, rather than the EMPNO primary key. My first attempts
    to make the joined view with EMPNO also gave the same error). I
    wrote a PL/SQL trigger than would make sure that EMPNO_DUP and
    EMPNO remain in synch if EMPNO is updated or if there is an
    INSERT on EMP. Then I created a joined view of EMP and RELATIVE
    with:
    CREATE OR REPLACE VIEW EMPREL
    (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, EMPNO_DUP
    IDREL, EMPNUM, RNAME, TEL, STREET, CITY, STATE, ZIP, COUNTRY)
    AS SELECT
    E.EMPNO, E.ENAME, E.JOB, E.MGR, E.HIREDATE, E.SAL, E.COMM,
    E.DEPTNO,E.EMPNO_DUP,
    R.IDREL, R.EMPNUM, R.RNAME, R.TEL, R.STREET, R.CITY, R.STATE,
    R.ZIP, R.COUNTRY
    FROM EMP E, RELATIVE R WHERE E.EMPNO_dup=R.EMPNUM;
    I tried to insert the XML document shown at the bottom with:
    java OracleXML putXML -user %USER_PASSWORD% -filename myfile.xml
    myView
    I also tried the direct SQL command:
    INSERT INTO EMPREL
    (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO,EMPNO_DUP,
    IDREL, EMPNUM, RNAME, TEL, STREET, CITY, STATE, ZIP, COUNTRY)
    VALUES
    (7944, 'WIZARD', 'CLERK', 7782, '25-JUL-82', 1325, 0, 10, 7944,
    1, 7944, 'SUE', 4087200111, '200 MAIN ST.', 'PALO ALTO', 'CA',
    '94043', 'USA')
    Both attempts resulted in this error message:
    "cannot modify a column which maps to a non key-preserved table"
    I would really appreciate an example of how to create an
    updatable view where two or more underlying tables can be
    modified. Thanks.
    Regards
    Mehran Moshfeghi
    Here is the sample XML file. I want the first set of elements to
    map to EMP table columns and the second set of elements (after
    the blank line) to map to the RELATIVE table columns.
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <EMPNO>7942</EMPNO>
    <ENAME>GUNNEL</ENAME>
    <JOB>CLERK</JOB>
    <MGR>7782</MGR>
    <HIREDATE>1982-02-25 00:00:00.0</HIREDATE>
    <SAL>1350</SAL>
    <DEPTNO>10</DEPTNO>
    <EMPNO_DUP>7942</EMPNO_DUP>
    <IDREL>2</IDREL>
    <RNAME>SMITH</RNAME>
    <TEL>6504262551</TEL>
    <STREET>2171 LANDINGS DRIVE</STREET>
    <CITY>MOUNTAIN VIEW</CITY>
    <STATE>CA</STATE>
    <ZIP>94043-0837</ZIP>
    <COUNTRY>USA</COUNTRY>
    </ROW>
    </ROWSET>
    null

    Hi Mehran,
    This is a classic view update problem where the database cannot
    figure out automatically which table(s) to update given a join
    view. Any update/insert/delete cannot act on more than one
    table.So if you are updating a column in a join-view, then that
    column must map to a particular column of a single table
    unambigously. You should look at the documentation on updatable
    join views.
    One of the easiest solutions to your problem is to create
    INSTEAD-OF trigger on those views. INSTEAD-OF triggers are
    triggers that can be created over non-updatable views to make
    them updatable. Here in the trigger body you specify the
    appropriate insert statements into the base tables. So your view
    can be as complicated as possible and yet updatable using these
    triggers.
    Thx
    oracle XML team
    Mehran (guest) wrote:
    : Hi
    : I would like to insert an XML document into two tables (some
    : elements into table 1 and some into table 2). I have created a
    : joined view of the two tables and have tried to insert into
    the
    : view with:
    : java OracleXML putXML -user %USER_PASSWORD% -filename
    myfile.xml
    : myView
    : But I get the error "cannot modify a column which maps to a
    non
    : key-preserved table". PLEASE GIVE A SPECIFIC EXAMPLE OF AN
    : UPDATABLE 'VIEW' WHERE AN INSERT CAN MODIFY MORE THAN ONE
    : UNDERLYING TABLE. Is it possible?
    : Any example will do. But here is what I tried to do. I tried
    : to map the first few ROW child elements of an XML document
    (shown
    : at the bottom) into columns of the EMP table and the remaining
    : child
    : elements into another table called RELATIVE (this is a table
    : containing next-of-kin contact information for each employee).
    I
    : created a RELATIVE table with:
    : CREATE TABLE RELATIVE (
    : IDREL NUMBER(15) PRIMARY KEY,
    : EMPNUM NUMBER(4) CONSTRAINT FK_REL REFERENCES SCOTT.EMP
    (EMPNO),
    : RNAME VARCHAR2(20) NOT NULL,
    : TEL NUMBER(14),
    : STREET VARCHAR2(30),
    : CITY VARCHAR2(20),
    : STATE VARCHAR2(10),
    : ZIP VARCHAR2(12),
    : COUNTRY VARCHAR2(20)
    : I added a EMPNO_DUP column to the EMP table that is a copy of
    : the
    : EMPNO primary key (I did this so as to use EMPNO_DUP for the
    two
    : table join, rather than the EMPNO primary key. My first
    attempts
    : to make the joined view with EMPNO also gave the same error).
    I
    : wrote a PL/SQL trigger than would make sure that EMPNO_DUP and
    : EMPNO remain in synch if EMPNO is updated or if there is an
    : INSERT on EMP. Then I created a joined view of EMP and
    RELATIVE
    : with:
    : CREATE OR REPLACE VIEW EMPREL
    : (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, EMPNO_DUP
    : IDREL, EMPNUM, RNAME, TEL, STREET, CITY, STATE, ZIP, COUNTRY)
    : AS SELECT
    : E.EMPNO, E.ENAME, E.JOB, E.MGR, E.HIREDATE, E.SAL, E.COMM,
    : E.DEPTNO,E.EMPNO_DUP,
    : R.IDREL, R.EMPNUM, R.RNAME, R.TEL, R.STREET, R.CITY, R.STATE,
    : R.ZIP, R.COUNTRY
    : FROM EMP E, RELATIVE R WHERE E.EMPNO_dup=R.EMPNUM;
    : I tried to insert the XML document shown at the bottom with:
    : java OracleXML putXML -user %USER_PASSWORD% -filename
    myfile.xml
    : myView
    : I also tried the direct SQL command:
    : INSERT INTO EMPREL
    : (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO,EMPNO_DUP,
    : IDREL, EMPNUM, RNAME, TEL, STREET, CITY, STATE, ZIP, COUNTRY)
    : VALUES
    : (7944, 'WIZARD', 'CLERK', 7782, '25-JUL-82', 1325, 0, 10, 7944,
    : 1, 7944, 'SUE', 4087200111, '200 MAIN ST.', 'PALO
    ALTO', 'CA',
    : '94043', 'USA')
    : Both attempts resulted in this error message:
    : "cannot modify a column which maps to a non key-preserved
    table"
    : I would really appreciate an example of how to create an
    : updatable view where two or more underlying tables can be
    : modified. Thanks.
    : Regards
    : Mehran Moshfeghi
    : Here is the sample XML file. I want the first set of elements
    to
    : map to EMP table columns and the second set of elements (after
    : the blank line) to map to the RELATIVE table columns.
    : <?xml version="1.0"?>
    : <ROWSET>
    : <ROW>
    : <EMPNO>7942</EMPNO>
    : <ENAME>GUNNEL</ENAME>
    : <JOB>CLERK</JOB>
    : <MGR>7782</MGR>
    : <HIREDATE>1982-02-25 00:00:00.0</HIREDATE>
    : <SAL>1350</SAL>
    : <DEPTNO>10</DEPTNO>
    : <EMPNO_DUP>7942</EMPNO_DUP>
    : <IDREL>2</IDREL>
    : <RNAME>SMITH</RNAME>
    : <TEL>6504262551</TEL>
    : <STREET>2171 LANDINGS DRIVE</STREET>
    : <CITY>MOUNTAIN VIEW</CITY>
    : <STATE>CA</STATE>
    : <ZIP>94043-0837</ZIP>
    : <COUNTRY>USA</COUNTRY>
    : </ROW>
    : </ROWSET>
    Oracle Technology Network
    http://technet.oracle.com
    null

  • About insert into MDSYS.SDO_GEOM_METADATA_TABLE

    Hi all,
    I'm newbie with Oracle Spatial.
    I would like to know what values can I define to columns SDO_LB and SDO_UB
    for the dim element for SRID 8292 when I insert into table
    MDSYS.SDO_GEOM_METADATA_TABLE.
    I found the following example:
    INSERT INTO MDSYS.SDO_GEOM_METADATA_TABLE
           SDO_OWNER, SDO_TABLE_NAME, SDO_COLUMN_NAME,
           SDO_DIMINFO,
           SDO_SRID)
    VALUES('PROJUSER', 'LOCAL', 'CD_LOCAL',
    MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 500000, 600000, 0.05),
                        MDSYS.SDO_DIM_ELEMENT('Y', 7000000, 7020000, 0.05)),
    8292);But I don't know if this insert is correct and the spatial index
    is valid for SRID 8292.
    Thank you very much!!!
    []´s

    Hi,
    8292 is a Geographic system, so this is the correct entry for metadata:
    insert into user_sdo_geom_metadata values ( ...,
    SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -180, 180, .05),
    SDO_DIM_ELEMENT('Y', -90, 90, .05)), 8292);
    And you should never insert directly into the MDSYS.SDO_GEOM_METADATA_TABLE table.
    You should always insert into USER_SDO_GEOM_METADATA view.
    siva

  • Insert order by records into a view with a instead of trigger

    Hi all,
    I have this DML query:
    INSERT INTO table_view t (a,
                              b,
                              c,
                              d,
                              e)
          SELECT   a,
                   b,
                   c,
                   d,
                   e
            FROM   table_name
        ORDER BY   dtable_view is a view with an INSTEAD OF trigger and table_name is a table with my records to be inserted.
    I need the ORDER BY clause because in my trigger i call a procedure who treat each record and insert into a table, used in the view. I need to garantee these order.
    If i put an other SELECT statement outside, like this:
    INSERT INTO table_view t (a,
                              b,
                              c,
                              d,
                              e)
          SELECT   a,
                   b,
                   c,
                   d,
                   e
            FROM   table_name
        ORDER BY   dIt works. But I can put these new SELECT because these query is created automatic by Oracle Data Integrator.
    What I'm asking you is if there any solution to this problem without changing anything in the Oracle Data Integrator. Or, in other words, if there is any simple solution other than to add a new SELECT statement.
    Thanks in advance,
    Regards.

    Sorry... copy+paste error :)
    INSERT INTO table_view t (a,
                              b,
                              c,
                              d,
                              e)
        SELECT   *
          FROM   (  SELECT   a,
                             b,
                             c,
                             d,
                             e
                      FROM   table_name
                  ORDER BY   d)I need to insert him by a D column order, because my trigger needs to validate each record and insert him. I have some restrictions. For example, my records are:
    2     1     2006     M
    1     2     2007 M
    1     3     2007     S 2007
    1     2     2007     S 2007
    2     1     2009     S
    2     1     2009     S
    I want to insert the 'M' records first and then the 'S' records because the 'S' records only makes sense in target table is exists 'M' records
    Regards,
    Filipe Almeida

  • Inserting into a base table of a materialized view takes lot of time.......

    Dear All,
    I have created a materialized view which refreshes on commit.materialized view is enabled query rewrite.I have created a materialized view log on the base table also While inserting into the base table it takes lot of time................Can u please tell me why?

    Dear Rahul,
    Here is my materialized view..........
    create materialized view mv_test on prebuilt table refresh force on commit
    enable query rewrite as
    SELECT P.PID,
    SUM(HH_REGD) AS HH_REGD,
    SUM(INPRO_WORKS) AS INPRO_WORKS,
    SUM(COMP_WORKS) AS COMP_WORKS,
    SUM(SKILL_WAGE) AS SKILL_WAGE,
    SUM(UN_SKILL_WAGE) AS UN_SKILL_WAGE,
    SUM(WAGE_ADVANCE) AS WAGE_ADVANCE,
    SUM(MAT_AMT) AS MAT_AMT,
    SUM(DAYS) AS DAYS,
    P.INYYYYMM,P.FIN_YEAR
    FROM PROG_MONTHLY P
    WHERE SUBSTR(PID,5,2)<>'PP'
    GROUP BY PID,P.INYYYYMM,P.FIN_YEAR;
    Please help me if query enable rewrite does any performance degradation......
    Thanks & Regards
    Kris

  • Inserting data into a view

    Hi,
    How to insert data into a view of one table

    Same as for the underlying table:
    INSERT INTO <view_name>(<col1>, <col2>, ..., <coln>) VALUES (<val1>, <val2>, ..., <valn>);
    Cheers,
    Colin

  • Insert into multiple table view

    I have a view with multiple table query and and INSTEAD OF trigger on the view that inserts into multiple tables. When I attempt to do a commit out of a ADF Creation Form, I get the following error: ORA-01779: cannot modify a column which maps to a non key-preserved table ORA-06512: at line 1.
    Has anyone had success inserting into multiple tables via a view that has more than one table?
    Thanks,
    Lisa

    Lisa,
    Sounds like your instead-of trigger may not be being called and you are trying to insert directly into the view.
    I did write a [url http://stegemanoracle.wordpress.com/2006/03/15/using-updatable-views-with-adf/]blog entry about using a view with instead-of triggers last year.
    John

  • Need code for dynamic insertion of a MIME object(image) into WebDynpro View

    Hi experts,
    I am attempting to insert an image into a view at runtime, using lines of code.
    I know that this code must be present in the WDDOMODIFYVIEW method of that particular view.
    However I am not sure about the lines of code which can do this. Can anyone please help me out with this........
    Thanks in advance,
    Adithya.

    Hi.,
    Yes you can add MIME at runtime ., Check this.,
    [MIME at run in WDA |Can mime object be created at run-time?;
    also ., [Display logo at runtime in WDA|Mime logo not displaying;
    hope this helps u.,
    Thanks & Regards
    Kiran

  • Inserting into a doubly nested table through an object view

    Can anyone give me an example of an INSTEAD OF trigger that will mediate an INSERT into a doubly nested table of an Object View? Is there syntax that will allow it?

    Here's some code to demonstrate. Note that relational tables, not an object table, are used to store object instances:
    create or replace type TInnerNestedTable
    is table of varchar2(20)
    create or replace type TOuterNestedTable
    is table of TInnerNestedTable
    create or replace type TMyObject
    is object
         id     varchar2(20)
    ,     tab     TOuterNestedTable
    create
    table     T_MY_OBJECT
         id          varchar2(20)     not null
    ,     primary key (id)
    create
    table     T_MY_OBJECT_TAB_OUTER
         id          varchar2(20)     not null
    ,     outerIndex     integer          not null
    ,     primary key (id, outerIndex)
    ,     foreign key (id) references T_MY_OBJECT on delete cascade
    create
    table     T_MY_OBJECT_TAB_INNER
         id          varchar2(20)     not null
    ,     outerIndex     integer          not null
    ,     innerIndex     integer          not null
    ,     innerValue     varchar2(20)
    ,     primary key (id, outerIndex, innerIndex)
    ,     foreign key (id, outerIndex) references T_MY_OBJECT_TAB_OUTER on delete cascade
    create or replace view V_MY_OBJECT
    of TMyObject
    with object identifier (id)
    as
    select     t.id
    ,     cast(multiset(
              select     cast(multiset(
                        select     i.innerValue
                        from     T_MY_OBJECT_TAB_INNER i
                        where     i.id = o.id
                        and     i.outerIndex = o.outerIndex
                   ) as TInnerNestedTable)
              from     T_MY_OBJECT_TAB_OUTER o
              where     o.id = t.id
         ) as TOuterNestedTable)
    from     T_MY_OBJECT t
    create or replace trigger TR_II_V_MY_OBJECT
    instead of insert on V_MY_OBJECT
    for each row
    begin
         insert
         into     T_MY_OBJECT
              id
         values     (
              :new.id
         insert
         into     T_MY_OBJECT_TAB_OUTER
              id
         ,     outerIndex
         select     :new.id
         ,     rownum
         from     table(:new.tab) o;
         insert
         into     T_MY_OBJECT_TAB_INNER
              id
         ,     outerIndex
         ,     innerIndex
         ,     innerValue
         select     :new.id
         ,     o.outerIndex
         ,     rownum
         ,     value(i)
         from     (
              select     :new.id
              ,     rownum outerIndex
              ,     value(o) innerTab
              from     table(:new.tab) o
              ) o
         ,     table(o.innerTab) i;
    end;
    insert
    into     V_MY_OBJECT
    values     (
         new TMyObject(
              'A'
         ,     TOuterNestedTable(
                   TInnerNestedTable('A','B','C')
              ,     TInnerNestedTable('AA')
              ,     TInnerNestedTable('AB')
    insert
    into     V_MY_OBJECT
    values     (
         new TMyObject(
              'B'
         ,     TOuterNestedTable(
                   TInnerNestedTable('X','Y','Z')
              ,     TInnerNestedTable('Hello', 'World!')
    /Selecting from the view shows the results:
    select     value(o)
    from     V_MY_OBJECT o
    VALUE(O)(ID, TAB)
    TMYOBJECT('A', TOUTERNESTEDTABLE(TINNERNESTEDTABLE('A', 'B', 'C'), TINNERNESTEDTABLE('AA'), TINNERNESTEDTABLE('AB')))
    TMYOBJECT('B', TOUTERNESTEDTABLE(TINNERNESTEDTABLE('X', 'Y', 'Z'), TINNERNESTEDTABLE('Hello', 'World!')))
    2 rows selected.Hope that helps...
    Gerard

  • Problem inserting XML into object view

    Hi all,
    My environment is :
    Windows NT 4.0
    Oracle 8i 8.1.5
    (NLS_CHARACTERSET = EL8MSWIN1253)
    Apache 1.3.11 Web Server
    Apache JServ 1.1
    XSQL v 0.9.9.1 and XML parser for Java v2,
    XMLSQL that come with it
    I've created an object view as following :
    create table schedules (
    schedule_id varchar2(20),
    description varchar2(100),
    constraint pk_schedule_id primary key (schedule_id)
    create table schedule_details (
    schedule_id varchar2(20),
    starting_time date,
    duration number,
    constraint pk_schedule_dtls primary key (schedule_id, starting_time),
    constraint fk_schedule_id foreign key (schedule_id) references schedules (schedule_id)
    create or replace type schedule_detail_t as object (
    starting_time varchar2(20),
    duration number
    create or replace type schedule_detail_list as table of schedule_detail_t;
    create or replace type schedule_details_t as object (
    schedule_id varchar2(20),
    description varchar2(100),
    details schedule_detail_list
    create or replace view schedule_details_view of schedule_details_t
    with object OID (schedule_id)
    as select schedule_id, description,
    cast(multiset(select schedule_detail_t (to_char(starting_time, 'hh24:mi'), duration) as Detail
    from schedule_details
    where schedule_details.schedule_id = schedules.schedule_id
    ) as schedule_detail_list )
    from schedules;
    And I'm trying to insert using putXML this
    <?xml version = "1.0" encoding = "ISO-8859-1"?>
    <ROWSET>
    <ROW>
    <SCHEDULE_ID>S1112</SCHEDULE_ID>
    <DESCRIPTION>Working 08:00 to 20:00</DESCRIPTION>
    <DETAILS>
    <DETAILS_ITEM>
    <STARTING_TIME>08:00</STARTING_TIME>
    <DURATION>12</DURATION>
    </DETAILS_ITEM>
    </DETAILS>
    </ROW>
    </ROWSET>
    The error I get is
    oracle.xml.sql.OracleSQLXMLException:
    non supported oracle-character-set-174
    Note: no rows have been inserted
    at oracle.xml.sql.dml.OracleXMLSave.insertXML
    When I'm posting using XSQL the XML doesn't get inserted with no error message.
    But when I try this for a change
    <?xml version = "1.0" encoding = "ISO-8859-1"?>
    <ROWSET>
    <ROW>
    <SCHEDULE_ID>S1111</SCHEDULE_ID>
    <DESCRIPTION>Working 08:00 to 20:00</DESCRIPTION>
    </ROW>
    </ROWSET>
    Trying to insert into table (this time) "schedules" using putXML it works ...
    It works on tables and it doesn't work on object views.
    Any piece of advice will be highly appreciated.
    Nick

    No known limitations. Please post the sample DDL to create your object types and object view, along with an example of the example XML document you're trying to insert.

  • Inserting into views

    Hi everybody.
    I have a question regarding inserting data through views.
    One can insert and delete rows through a view only if the view definition doesn't have the following:1. Distint clause
    2. Group By clause
    3. Start With clause
    4. Connect By clause
    5. ROWNUM clause
    6. Subquery in the select clause
    7. Set operators
    Can you please tell me why is this restriction placed?

    For the same reason we can't do DML with views that are joins of more than one table: a row in the view does not, cannot map to a single row in the underlying table (or, in the case of ROWNUM, to a column in that table).
    If you have a need to do this sort of thing you need to investigate INSTEAD OF triggers. But approach with caution.
    Cheers, APC

Maybe you are looking for

  • Itunes 10.6.0.40 Stops Working

    I have been having trouble accessing ITunes since Thursday March 15th.  I open ITunes and it starts to run Match and download podcasts and usually crashes within a minute.  A couple times I have stopped Match from running and it has not crashed, but

  • [SOLVED]Unable to boot in UEFI mode from CD

    Hello gents! Here's the problem: According to the beginner's guide I followed the instruction to test if I am in UEFI mode: In case you have a UEFI motherboard, the CD/USB will launch UEFI Shell and display a message that startup.nsh script will be l

  • Installed Boot Camp w/o having Windows Disk, Installed Parallels, now what?

    I installed Boot Camp not really knowing what was required, thinking that it was a download, not knowing it came with the computer. I then deleted it, thinking I could re-download it later since I didn't have a copy of the Windows OS, and now I still

  • Upgraded to CC and eraser outline doesn't show

    So I upgraded and when I use the Eraser or Brush tool the outline that shows the size of the brush stopped showing. What's weird is that I hit Command + Alt + Shift, which brought it back; however, if I zoom in then it disappears again and when I zoo

  • Photosmart 7510 Prints the text offset to the right

    I use  MS Word 2010 and when I print text it appears offset 7 mm to the right. e.g. Left margin set at13 mm starts printing at 20 mm, and Right Margin set at19 mm stops printing at 12 mm. The same offset appears when using other applications e.g. Pub