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.

Similar Messages

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

  • Can't open a object view with mapinfo

    i have created this object view (with toad 7.6 in a server oracle 9i ITA, i use mapinfo 7.5 ITA):
    CREATE OR REPLACE FORCE VIEW PRG.VISTAMORD
    (PIANO_STORIA_ID, ANAGR_ID, PIANO_ID, TIPOMOD_COD, ZTO,
    PRG, PIANO_STATO, ATTO_DATA, ATTO_TIPO, ATTO_NUM,
    PIANO_VARIANTE, PIANO_NOME, PIANO_NOTE, PIANO_POS_ARCH, PIANO_LEGGE,
    ANAGR_COD_COM, MI_STYLE, MI_PRINX, GEOLOC, ST)
    AS
    SELECT a.Piano_storia_id, a.Anagr_id, a.Piano_id, a.tipomod_cod,
    a.ZTO, a.PRG, b.piano_stato, b.atto_data, b.atto_tipo, b.atto_num,
         b.piano_variante, b.piano_nome, b.piano_note,
         b.piano_pos_arch, b.piano_legge, c.anagr_cod_com,
         d.mi_style, d.mi_prinx, d.geoloc, d.st
    from (piano b inner join ((oggetti_storia a
    inner join aux_indice e on (a.piano_storia_id=e.piano_storia_id)
              and (a.anagr_id=e.anagr_id) and
    (a.piano_id=e.piano_id)) inner join anagrafica c on a.anagr_id = c.anagr_id)
         on b.piano_id = a.piano_storia_id) inner join oggetti_spazial d
              on a.anagr_id = d.anagr_id
    where ((a.tipomod_cod)<>'DEL')
    order by piano_storia_id;
    where oggetti_spazial is a object table (a mapinfo map imported in Oracle)
    if i don't add the order by clause the view is ok and i can open it in mapinfo,
    with the order by clause, when i try to open the view mapinfo give the error:
    "errore Oracle: ORA-00600: codice errore INT., argom.:[15819],[5582],[],[],[],[],[],[]. Impossibile recuperare i record nella tavola.
    can You Help me?

    Hi Gabriel,
    I think with enough patience one could get the ASCII DataPlugin Wizard to create a DataPlugin that would work for your file, but the resulting code generated by the wizard is not easily understandable, and it would not have correctly devined the sampling rate from your file format.  I've written a DataPlugin from scratch which correctly reads the data snippet you sent over.  I included an implicit time channel so that you could easily see the time values inferred from the "SampleRate" line.  The implicit time channel rerquires all the lines in the ASCII file to be parsed in order to figure out the correct channel length (line 58), so if you have large data files you should comment out the time channel lines (44, 45, 58) and use just the implict time information already encoded in the data channel waveform properties (for faster file indexing).  Unless your files are verry large, though, I think you'll like the DataPlugin as it is.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments
    Attachments:
    Fischerg_TXT.zip ‏2 KB

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

  • 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

  • Problem with object view with primary-key based object identifier

    Hello!
    I met such problem.
    t1 is persinstent-capable class:
    class t1 : public PObject { .... };
    T1OV is object view, based on object table T1OT
    I1 is primary key of the table T1OT.
    Next code:
    t1* t = new (conn, "T1OV") t1(...);
    conn->commit();
    try
    t->markDelete();
    conn->commit(); // exception throws here
    Works fine if T1OV defined as:
    create view t1ov of t1 with object identifier default
    as select * from t1ot;
    And throws an exception
    "ORA-22883: object deletion failed"
    if:
    create view t1ov of t1 with object identifier (I1)
    as select * from t1ot;
    Such problem also occurs when object view is based on relational table/view (OID is primary-key based).
    Also it occurs when
    t->markModified() used insted of t->markDelete()
    I am using Oracle 9i second release for windows and
    MS VC++
    Thank You

    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_85a.htm#2065512
    You can specify constraints on views and object views. You define the constraint at the view level using the out_of_line_constraint clause. You define the constraint as part of column or attribute specification using the inline_constraint clause after the appropriate alias.
    Oracle does not enforce view constraints. However, operations on views are subject to the integrity constraints defined on the underlying base tables. This means that you can enforce constraints on views through constraints on base tables.
    Restrictions on View Constraints
    View constraints are a subset of table constraints and are subject to the following restrictions:
    You can specify only unique, primary key, and foreign key constraints on views. However, you can define the view using the WITH CHECK OPTION clause, which is equivalent to specifying a check constraint for the view.
    Because view constraints are not enforced directly, you cannot specify INITIALLY DEFERRED or DEFERRABLE.
    View constraints are supported only in DISABLE NOVALIDATE mode. You must specify the keywords DISABLE NOVALIDATE when you declare the view constraint, and you cannot specify any other mode.
    You cannot specify the using_index_clause, the exceptions_clause clause, or the ON DELETE clause of the references_clause.
    You cannot define view constraints on attributes of an object column.
    Rgds.

  • Weird problem w. mysql 4.0 when inserting  into a table with auto_incremet

    Since I upgraded my mysql database from 3.23 to 4.0.1
    the following code does not work anymore:
    I get this error msg:
    <b>"Invalid argument value: Duplicate entry '2147483647' for key 1"</b>
    <code>
    package mysql4test;
    import java.sql.*;
    class test {
    public test() {
    public static void main(String[] args) {
    Connection connection = null;
    Statement st = null;
    try {
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    connection = DriverManager.getConnection
    ("jdbc:mysql://192.168.0.4/x?user=x&password=");
    st = connection.createStatement();
    for (int i=1;i<10;i++)
    String insert = "insert into x (b) values('hello');";
    System.out.println(insert);
    st.executeUpdate(insert);
    } catch (Exception ex) { System.err.println(ex.getMessage());}
    </code>
    The table definition of table x is the following:
    create table x(a int(11) primary key auto_increment, b varchar(10));
    What makes the thing even more mysterious is, that doing the same thing as this programm does manually on an mysql client does not produces any error message.
    insert into x (b) values('hello'); works fine on the mysql client deliverd with the server.

    Hi eggsurplus!
    Yes, I succeeded in different ways to solve the problem. changing the table was one of it. but the problem is that i can't simply change all tables (there are a lot) as the are used in other programms.
    The simplest solution that i figured out so far was changing the insert from
    insert into x (b) values('hello')
    to
    insert into x (a,b) values("+i+",'hello')"
    But this solution is still not satisfactory as in more complex programs you can't just use the i variable of the for loop, but you have to add a new variable that increments on every insert.
    This still means changing a lot of code that i wrote for mysql 3.x.
    Besides, i tried also another jdbc driver and it still didn't work.
    The same bug was reported in a PHP forum, but without solution

  • How to insert into a table with a nested table which refer to another table

    Hello everybody,
    As the title of this thread might not be very understandable, I'm going to explain it :
    In a context of a library, I have an object table about Book, and an object table about Subscriber.
    In the table Subscriber, I have a nested table modeling the Loan made by the subscriber.
    And finally, this nested table refers to the Book table.
    Here the code concerning the creation of theses tables :
    Book :
    create or replace type TBook as object
    number int,
    title varchar2(50)
    Loan :
    create or replace type TLoan as object
    book ref TBook,
    loaning_date date
    create or replace type NTLoan as table of TLoan;
    Subscriber :
    create or replace type TSubscriber as object
    sub_id int,
    name varchar2(25)
    loans NTLoan
    Now, my problem is how to insert into a table of TSubscriber... I tried this query, without any success...
    insert into OSubscriber values
    *(1, 'LEVEQUE', NTLoan(*
    select TLoan(ref(b), '10/03/85') from OBook b where b.number = 1)
    Of course, there is an occurrence of book in the table OBook with the number attribute 1.
    Oracle returned me this error :
    SQL error : ORA-00936: missing expression
    00936. 00000 - "missing expression"
    Thank you for your help

    1) NUMBER is a reserved word - you can't use it as identifier:
    SQL> create or replace type TBook as object
      2  (
      3  number int,
      4  title varchar2(50)
      5  );
      6  /
    Warning: Type created with compilation errors.
    SQL> show err
    Errors for TYPE TBOOK:
    LINE/COL ERROR
    0/0      PL/SQL: Compilation unit analysis terminated
    3/1      PLS-00330: invalid use of type name or subtype name2) Subquery must be enclosed in parenthesis:
    SQL> create table OSubscriber of TSubscriber
      2  nested table loans store as loans
      3  /
    Table created.
    SQL> create table OBook of TBook
      2  /
    Table created.
    SQL> insert
      2    into OBook
      3    values(
      4           1,
      5           'No Title'
      6          )
      7  /
    1 row created.
    SQL> commit
      2  /
    Commit complete.
    SQL> insert into OSubscriber
      2    values(
      3           1,
      4           'LEVEQUE',
      5           NTLoan(
      6                  (select TLoan(ref(b),DATE '1985-10-03') from OBook b where b.num = 1)
      7                 )
      8          )
      9  /
    1 row created.
    SQL> select  *
      2    from  OSubscriber
      3  /
        SUB_ID NAME
    LOANS(BOOK, LOANING_DATE)
             1 LEVEQUE
    NTLOAN(TLOAN(000022020863025C8D48614D708DB5CD98524013DC88599E34C3D34E9B9DBA1418E49F1EB2, '03-OCT-85'))
    SQL> SY.

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

  • Taking More Time while inserting into the table (With foriegn key)

    Hi All,
    I am facing problem while inserting the values into the master table.
    The problem,
    Table A -- User Master Table (Reg No, Name, etc)
    Table B -- Transaction Table (Foreign key reference with Table A).
    While inserting the data's in Table B, i need to insert the reg no also in table B which is mandatory. I followed the logic which is mentioned in the SRDemo.
    While inserting we need to query the Table A first to have the values in TableABean.java.
    final TableA tableA= (TableA )uow.executeQuery("findUser",TableA .class, regNo);
    Then, we need to create the instance for TableB
    TableB tableB= (TableB)uow.newInstance(TableB.class);
    tableB.setID(bean.getID);
    tableA.addTableB(tableB); --- this is for to insert the regNo of TableA in TableB.. This line is executing the query "select * from TableB where RegNo = <tableA.getRegNo>".
    This query is taking too much time if values are more in the TableB for that particular registrationNo. Because of this its taking more time to insert into the TableB.
    For Ex: TableA -- regNo : 101...having less entry in TableB means...inserting record is taking less than 1 sec
    regNo : 102...having more entry in TableB means...inserting record is taking more than 2 sec
    Time delay is there for different users when they enter transaction in TableB.
    I need to avoid this since in future it will take more time...from 2 sec to 10 sec, if volume of data increases mean.
    Please help me to resolve this issue...I am facing it now in production.
    Thanks & Regards
    VB

    Hello,
    Looks like you have a 1:M relationship from TableA to TableB, with a 1:1 back pointer from TableB to TableA. If triggering the 1:M relationship is causing you delays that you want to avoid there might be two quick ways I can see:
    1) Don't map it. Leave the TableA->TableB 1:M unmapped, and instead just query for relationship when you do need it. This means you do not need to call tableA.addTableB(tableB), and instead only need to call tableB.setTableA(tableA), so that the TableB->TableA relation gets set. Might not be the best option, but it depends on your application's usage. It does allow you to potentially page the TableB results or add other query query performance options when you do need the data though.
    2) You are currently using Lazy loading for the TableA->TableB relationship - if it is untriggered, don't bother calling tableA.addTableB(tableB), and instead only need to call tableB.setTableA(tableA). This of course requires using TopLink api to a) verify the collection is an IndirectCollection type, and b) that it is hasn't been triggered. If it has been triggered, you will still need to call tableA.addTableB(tableB), but it won't result in a query. Check out the oracle.toplink.indirection.IndirectContainer class and it's isInstantiated() method. This can cause problems though in highly concurrent environments, as other threads may have triggered the indirection before you commit your transaction, so that the A->B collection is not up to date - this might require refreshing the TableA if so.
    Change tracking would probably be the best option to use here, and is described in the EclipseLink wiki:
    http://wiki.eclipse.org/Introduction_to_EclipseLink_Transactions_(ELUG)#Attribute_Change_Tracking_Policy
    Best Regards,
    Chris

  • MS SQL Server 2014: Error inserting into Temp table with index and identity field

    In this thread, I mentioned a problem with SQL Server 2014:
    SQL Server 2014: Bug with IDENTITY INSERT ON
    The question was answered, it is a bug. To keep you informed on this issue, I open this discussion.
    Problem:
    The code below works perfectly fine on MS SQL Server 2008 R2 and MS SQL Server 2012, but gives an error every second time the proc is executed on MS SQL Server 2014. If I do not define any index on the temp table, the problem disappears. Defining the index
    after the insert, does not help.
    SET NOCOUNT ON
    GO
    IF EXISTS (SELECT 1 FROM sys.procedures WHERE name = 'usp_Test') DROP PROC dbo.usp_Test;
    GO
    CREATE PROC dbo.usp_Test AS
    BEGIN
    SET NOCOUNT ON
    CREATE TABLE #Source(ID integer NOT NULL);
    INSERT INTO #Source VALUES (1), (2), (3);
    CREATE TABLE #Dest (ID integer IDENTITY(1,1) NOT NULL);
    CREATE INDEX #IDX_Dest ON #Dest (ID);
    PRINT 'Check if the insert might cause an identity crisis';
    SELECT 'Source' AS SourceTable, * FROM #Source;
    SELECT 'Destination' AS DestTable, * FROM #Dest;
    SET IDENTITY_INSERT #Dest ON;
    PRINT 'Do the insert';
    INSERT INTO #Dest (ID) SELECT ID FROM #Source;
    PRINT 'Insert ready';
    SET IDENTITY_INSERT #Dest OFF;
    SELECT * FROM #Dest;
    DROP TABLE #Source;
    DROP TABLE #Dest;
    END;
    GO
    PRINT 'First execution of the proc, everything OK';
    EXEC dbo.usp_Test;
    PRINT '';
    PRINT 'Second execution of the proc, the insert fails.';
    PRINT 'Removing the index #IDX_Dest causes the error to disappear.';
    EXEC dbo.usp_Test;
    GO
    DROP PROC dbo.usp_Test;
    GO

    There is some progress. Communication from a former Microsoft employee tells us this:
    Shivendra Vishal
    Engineer at Microsoft
    I am no longer with MS, and I do not have code access, however from the public symbols, I could make out following:
    sqlmin!SetidentI2I4+0x1f3:
    000007fe`f4d865d3 488b10 mov rdx,qword ptr [rax] ds:00000000`00000000=????????????????
    ExceptionAddress: 000007fef4d865d3 (sqlmin!SetidentI2I4+0x00000000000001f3)
    ExceptionCode: c0000005 (Access violation)
    ExceptionFlags: 00000000
    NumberParameters: 2
    Parameter[0]: 0000000000000000
    Parameter[1]: 0000000000000000
    Attempt to read from address 0000000000000000
    This is a read AV and from registers it is clear that we were trying to move the value of location pointed by qword of register rax which is not valid:
    rax=0000000000000000 rbx=0000000000000038 rcx=0000000000001030
    rdx=0000000000000006 rsi=00000001f55def98 rdi=00000000106fd070
    rip=000007fef4d865d3 rsp=00000000106fcf40 rbp=00000000106fcfe9
    r8=0000000000000000 r9=00000001f55def60 r10=00000001f55defa0
    r11=00000000106fcd20 r12=0000000000000000 r13=0000000000000002
    r14=00000001f49c3860 r15=00000001f58c0040
    iopl=0 nv up ei pl nz na po nc
    cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010206
    The stack is:
    # Child-SP RetAddr Call Site
    00 00000000`106fcf40 000007fe`f30c1437 sqlmin!SetidentI2I4+0x1f3
    01 00000000`106fd050 000007fe`f474e7ce sqlTsEs!CEsExec::GeneralEval4+0xe7
    02 00000000`106fd120 000007fe`f470e6ef sqlmin!CQScanUpdateNew::GetRow+0x43d
    03 00000000`106fd1d0 000007fe`f08ff517 sqlmin!CQueryScan::GetRow+0x81
    04 00000000`106fd200 000007fe`f091cebe sqllang!CXStmtQuery::ErsqExecuteQuery+0x36d
    05 00000000`106fd390 000007fe`f091ccb9 sqllang!CXStmtDML::XretDMLExecute+0x2ee
    06 00000000`106fd480 000007fe`f08fa058 sqllang!CXStmtDML::XretExecute+0xad
    07 00000000`106fd4b0 000007fe`f08fb66b sqllang!CMsqlExecContext::ExecuteStmts<1,1>+0x427
    08 00000000`106fd5f0 000007fe`f08fac2e sqllang!CMsqlExecContext::FExecute+0xa33
    09 00000000`106fd7e0 000007fe`f152cfaa sqllang!CSQLSource::Execute+0x86c
    0a 00000000`106fd9b0 000007fe`f152c9e8 sqllang!CStmtExecProc::XretLocalExec+0x25a
    0b 00000000`106fda30 000007fe`f152a1d8 sqllang!CStmtExecProc::XretExecExecute+0x4e8
    0c 00000000`106fe1e0 000007fe`f08fa058 sqllang!CXStmtExecProc::XretExecute+0x38
    0d 00000000`106fe220 000007fe`f08fb66b sqllang!CMsqlExecContext::ExecuteStmts<1,1>+0x427
    0e 00000000`106fe360 000007fe`f08fac2e sqllang!CMsqlExecContext::FExecute+0xa33
    0f 00000000`106fe550 000007fe`f0902267 sqllang!CSQLSource::Execute+0x86c
    10 00000000`106fe720 000007fe`f0909087 sqllang!process_request+0xa57
    11 00000000`106feee0 000007fe`f2bf49d0 sqllang!process_commands+0x4a3
    12 00000000`106ff200 000007fe`f2bf47b4 sqldk!SOS_Task::Param::Execute+0x21e
    13 00000000`106ff800 000007fe`f2bf45b6 sqldk!SOS_Scheduler::RunTask+0xa8
    14 00000000`106ff870 000007fe`f2c136ff sqldk!SOS_Scheduler::ProcessTasks+0x279
    15 00000000`106ff8f0 000007fe`f2c138f0 sqldk!SchedulerManager::WorkerEntryPoint+0x24c
    16 00000000`106ff990 000007fe`f2c13246 sqldk!SystemThread::RunWorker+0x8f
    17 00000000`106ff9c0 000007fe`f2c13558 sqldk!SystemThreadDispatcher::ProcessWorker+0x3ab
    18 00000000`106ffa70 00000000`775d59ed sqldk!SchedulerManager::ThreadEntryPoint+0x226
    19 00000000`106ffb10 00000000`7780c541 kernel32!BaseThreadInitThunk+0xd
    1a 00000000`106ffb40 00000000`00000000 ntdll!RtlUserThreadStart+0x21
    Unassembling the function:
    000007fe`f4d8658e 4c8b10 mov r10,qword ptr [rax]
    000007fe`f4d86591 4533e4 xor r12d,r12d
    000007fe`f4d86594 410fb7d5 movzx edx,r13w
    000007fe`f4d86598 4533c9 xor r9d,r9d
    000007fe`f4d8659b 4533c0 xor r8d,r8d
    000007fe`f4d8659e 488bc8 mov rcx,rax
    000007fe`f4d865a1 4489642420 mov dword ptr [rsp+20h],r12d
    000007fe`f4d865a6 41ff5230 call qword ptr [r10+30h]
    000007fe`f4d865aa 8b5597 mov edx,dword ptr [rbp-69h]
    000007fe`f4d865ad 4c8b10 mov r10,qword ptr [rax]
    000007fe`f4d865b0 4489642438 mov dword ptr [rsp+38h],r12d
    000007fe`f4d865b5 4489642430 mov dword ptr [rsp+30h],r12d
    000007fe`f4d865ba 458d442401 lea r8d,[r12+1]
    000007fe`f4d865bf 4533c9 xor r9d,r9d
    000007fe`f4d865c2 488bc8 mov rcx,rax
    000007fe`f4d865c5 c644242801 mov byte ptr [rsp+28h],1
    000007fe`f4d865ca 4488642420 mov byte ptr [rsp+20h],r12b
    000007fe`f4d865cf 41ff5250 call qword ptr [r10+50h]
    000007fe`f4d865d3 488b10 mov rdx,qword ptr [rax] <=================== AV happened over here
    000007fe`f4d865d6 488bc8 mov rcx,rax
    000007fe`f4d865d9 4c8bf0 mov r14,rax
    000007fe`f4d865dc ff5268 call qword ptr [rdx+68h]
    000007fe`f4d865df 488d55e7 lea rdx,[rbp-19h]
    000007fe`f4d865e3 4c8b00 mov r8,qword ptr [rax]
    000007fe`f4d865e6 488bc8 mov rcx,rax
    000007fe`f4d865e9 41ff5010 call qword ptr [r8+10h]
    000007fe`f4d865ed f6450a04 test byte ptr [rbp+0Ah],4
    I remember few issues with scan2ident function, I am not sure if they have fixed it however it appears that this is intoduced to SQL 2014 and we need help from MS to get this resolved as it needs code analysis.
    It is not getting simulated for other versions of SQL apart from SQL 2014.
    Also to add, interestingly, the value of rax is not visibly changed and it was successfully passed on to rcx, which has a valid value, so something should have changed the value of rax inside call to function using call qword ptr [r10+50h], and looking at this
    it appears that it might be a list of functions and we are going at particular offset [50h]. So, bottom line is that the call to function qword ptr [r10+50h], should be changing something in rax, and debugging/analyzing this code might give us some more idea.

  • Quite complext problem - INSERT into PAYMENTS

    I am trying to use the following code to insert data into the payments table. The code does work, the user is prompted for the order number (3 times - but this is ok). The fnext time this code is used the order number previously entered is used again without the user being prompted. This assignment is due in next week so any help would be great. The code is:
    INSERT into Payments values(Payments_seq.nextval, '&order_no', initcap('&Payment_Method'),
    (select sum(order_details.cost) from order_details WHERE '&order_no' = order_details.order_no),
    (select (orders.date_of_order+7) FROM orders where '&order_no' = orders.order_no), &Amount_Paid);
    The table we want to enter details is called 'payments' but we want details taken from order_details which is another table.
    Pam

    Use "&&order_no" to prevent re-prompting.
    Use "UNDEFINE order_no" to unset the variable.
    btw the problem would seem to be to do with setting and clearing SQL*Plus substitution variables, and nothing to do with inserting, payments tables or query complexity.

  • How can i insert pseudocolumn (sequencename.nextval) with oracleXmlSave?

    how can i insert pseudocolumn value (sequencename.nextval) with oracleXmlSave.insertXml(xmlfile)?
    if anyone know it, pls post the answer to the bbs or reply me: [email protected]
    thank u so much.

    You can create a trigger on the table and insert your sequence no from there or create a updateable view and create insted off trigger to populate your columns. I am new to XML, but I think this the way you can do it esealy. Or may be this the only way.

  • Problem inserting into tables

    Hello All, I hope that someone out there may be able to shed some light on my problem!!
    I have developed a series of JSP pages for my web site (using Tomcat 4.1)to allow a Customer to register themselves with the site. I have developed 3 corresponding JavaBeans to hold the details that the customer enters; a Customer bean, an Address bean and a Payment bean. In my database (MySQL) i have tables corresponding to each of these beans, which simply take the data inserted into a field by the user and create a new instance of each.
    Now, the above is all working fine and the database tables populate themselves exactly as they should; however, to allow a customer to add more than one address, or more than one payment method, I have developed the relationship tables 'hasaddress' and 'haspaymentdetails' to store the relevant id numbers in the database (i.e. hasaddress stores a customerid from the customer bean and an addressid from the address bean).
    Finally, i get round to my question!!..
    I am using the following jsp code to insert data into one such table:
    <------------------------------------------------------------------->
    <jsp:useBean id="registration" class="projectBeans.RegistrationBean" scope="session"/>
    //set the connection
    registration.setConnection(c);
    //retrieve the customer attribute
    projectBeans.Customer customer = (projectBeans.Customer)session.getAttribute("newCust");
    //retrieve the address attribute
    projectBeans.AddressBean address = (projectBeans.AddressBean)session.getAttribute("newAddr");
    //use the addCustomer method in the bean to create a new customer     
    registration.addCustomer(customer);
    //ditto for address
    registration.addAddressDetails(address);
    //populate the hasaddress table with the correct ids
    String table = "hasaddress";
    int customerid = customer.getCustomerId();
    int addressid = address.getAddressId();
    registration.updateRelationship(table, customerid, addressid);Both the addCustomer and addAddressDetail methods work fine, so below is just the code for updateRelationship method in the registrationBean:
    public void updateRelationship(String table, int id1, int id2) throws SQLException
       sta = c.prepareStatement("INSERT INTO "+table +" VALUES(?,?)");
       sta.setInt(1, id1);
       sta.setInt(2, id2);
       sta.executeUpdate();
    }I would expect this method to retrieve the newly assigned customer and address ids and enter them into the hasaddress table; however, when the page compiles and i look at the table it enters 0 for each of the fields (when it should, for example be entering 14 and 16):
    ----------+
    | cid | aid |
    ----------+
    | 0 | 0 |
    ----------+
    so my question is: does anyone have an idea as to why this is happening, or what may be wrong with my code for this to occur?
    Alternatively, am i being dumb and is there some way of getting MySql to handle the updates to the relationship table internally?
    Thanks in advance for any ideas,
    Cheers

    Try to specify you database field as SQL need field names to do updating
    sta = c.prepareStatement("INSERT INTO "+table + "("+ id1+","+id2+ ")"+ VALUES(?,?)");

  • Insert into temp table with sorting not works

    Hi,
    Am inserting some of the values into temp table . Before going to insert i will be sorting a cloumn in descending order and then i will try insert. But actually inserts in ascending order.Dont know why.
    Please find the code
    Create table #TempTable( column1 smalldateTime )
    Insert into #TempTable
    Select distinct(column1) from table1 where cloumn2 = 1 order by  column1 desc
    When i query the table
    select * from  #TempTable
    shows the dates are in ascending order instead it should in descending
    But when i query this Select distinct(column1) from table1 where cloumn2 = 1 order by  column1 desc
    dates are in descending order which means recent dates fills top

    Or use a CTE = Common Table Expression:
    CREATE TABLE #test (id int);
    INSERT INTO #test
    SELECT object_id
    FROM sys.objects;
    SELECT COUNT(*)
    FROM #test;
    GO
    ;WITH cte AS
    (SELECT Top 2 *
    FROM #test
    ORDER BY id desc)
    DELETE FROM cte;
    GO
    SELECT COUNT(*)
    FROM #test;
    GO
    DROP TABLE #test;
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

Maybe you are looking for

  • Can I share a USB drive connected to Airport Express

    I know that you can with the Extreme Base Station. Just curious if a drive connected to the Express would show up as a shared network drive

  • Opening Word-- blue screen-- all applications shutting down?

    Hi everyone! Today I closed my laptop to put it in sleep mode, it was not connected to power. I came back an hour or so later, opened it up, and entered my password to log in. It started to log in and then I got a blue screen! In a few seconds it bro

  • Expand or collapse all collapsible panels at once.

    Hi, I have a page with a number of collapsible panels on it generated from SpryData. I know the collapsible panel names because their IDs are generated from the Spry data with <div class="CollapsiblePanel" id="cp{ds_RowNumber}" spry:repeat="Events">

  • Tag cloud with autosuggest feature in ADF

    We want to select multiple records or words from a huge list so we tried autosuggestor which selects one record but if we want to add multiple words or records and show it like tag cloud as we add multiple email address in gmail then how can we achie

  • Drag and Drop not Working right

    Since last upgrading to 8.0.2 I have been experiencing problems when trying to Drag and Drop songs into playlists. When I click and hold a song to drag, it will not consistently hold the song. Sometimes it won't hold at all, sometimes when dragging i