Copy the data rows in the same table

Here is the structure of the table, I work I would like all the value with ID = 1 in new lines. The ID must be 2 with the same data.

I am using following query to accomplish, but get the error.

Insert into hsp_column_detail_item (DETAIL_ID, VALUE, POSITION, GENERATION, OPERATOR, LABEL)

Select 2, POSITION, GENERATION, OPERATOR, VALUE, LABEL

Of

hsp_column_detail_item

where

detail_id = 1

ORA-02291: integrity constraint (PLANSAMP. FK_HSP_DETAIL_ID) violated - key parent not found

Columns

Detail_ID1THEREINTEGER NUMBERFrequency
VALUE2THEREFLOATNone
POSITION3THEREINTEGER NUMBERNone
GENERATION4THEREINTEGER NUMBERNone
OPERATOR5THEREINTEGER NUMBERNone
LABEL6THEREVARCHAR2 (1500 bytes)None

Sample data:

Label Detail_ID value generation operator Position

1500001ABC

1300101def

1200201EFG

Index

Name of the indexColumn name

Col_Detail_ItemDetail_ID

Col_Detail_ItemPosition

866532 wrote:

Where detail_id in

(select detail_id in the hsp_column_detail where)

dim1 = (select object_id from hsp_object where the object_name = 'Real' and object_type = 31) and

Dim5 = (select object_id from hsp_object where the object_name = 'Work' and object_type = 35) and

dim7 = (select object_id from hsp_object where the object_name = 'FY13' and object_type = 38)

);

ORA-00001: unique constraint (PLANSAMP. Voilated PK_HSP_COL_DETAIL)

To not violate the unique constraint, two requirements:

-The detail_id 5 you insert would not already exist in the table

-Since you are forcing this detail_id, your subquery must return only one row: so you can write ' detail where id = (select...) "and:

-either the dim1 / dim5 / dim7 filters are quite selective

- or to make any decision on which detail_id to reproduce: max (detail_id) or min (detail_id) or any other way yo select the right / arbitrary

Tags: Database

Similar Questions

  • Update of several rows of the same table using trigger

    Hello

    I have the following table

    ---------------------------------------------------------------------------------------------------------

    CREATE TABLE ATT_PERMISSIONS
    (
    DATE OF PRMONTHYR,
    EMPIDNUMBER (10)DEFAULT VALUE 0,
    FROMDATETIMEDATE,
    TODMTFDATETIMEDATE,
    NUMBER OF PERMMINS (3),

    SSLINASTRETCH NUMBER (3).

    PERMATTINELIGIBLENUMBER (1)DEFAULT VALUE 0
    );

    ------------------------------------------------------------------------------------------------------

    I want to update the column PERMATTINELIGIBLE in the same table when each line is inserted.

    I created following trigger for that

    CREATE OR REPLACE TRIGGER SSL_AFTER_UPDATE AFTER UPDATE ON ATT_PERMISSIONS

    FOR EACH LINE

    BEGIN

    Update ATT_PERMISSIONS set PERMATTINELIGIBLE =

    (

    SELECT THE CHECK BOX

    WHEN PERMMINS < = 60

    or

    (

    PERMMINS < = SSLINASTRETCH

    AND

    COUNT (CASE WHEN PERMMINS = 0 THEN NULL OTHERWISE 1 END)

    COURSES (PARTITION BY empid, prmonthyr) < = 1

    )

    THEN 1

    0 OTHERWISE

    END

    FROM ATT_PERMISSIONS where prmonthyr =:new.prmonthyr, empid =:new.empid

    ) where prmonthyr =:new.prmonthyr, empid =:new.empid;

    END;

    ---------------------------------------------------------------------------------------------------

    That is to say.

    When a row is inserted the PERMATTINELIGIBLE of all records for this employee for the month is recalculated.

    There would be only two or three records for an employee for a month.

    PERMMINS is the number of minutes to use as short leave.

    If it is less than 60 is eligible for the bonus to attendance for this employee.

    If this isn't normally the date is not eligible for the attendance for this employee premium.

    but an exception is that if a short leaves of DISP employee allowed a month (IE. ( SSLINASTRETCH ) in a straight line, IE. one day, that day is eligible for the bonus of presence.

    That is to say. Why the number of short leaves in a month is taken. If it's one and done minutes use is lower to SSLINASTRETCH, then the day is eligible for the attendance bonus.

    But when I try to create the trigger I get error, PL/SQL: ORA-00907: missing a right parenthesis.

    Help, please

    I use oracle 10g

    I want to update the column PERMATTINELIGIBLE in the same table, when each row is inserted.

    No - you do NOT want to do in a trigger.

    You cannot query the same table that the trigger is activated on. -C' is a MUTANT and you will get an exception.

    When a row is inserted is recalculated to the PERMATTINELIGIBLE of all the records for that employee for that month.

    There would be only two or three records for an employee for a month.

    PERMMINS is the number of minutes to use as short leave.

    If it is less than 60 is eligible for the bonus to attendance for this employee.

    If is not normally the day is not eligible for the premium of attendance for this employee.

    but an exception is that if a short leaves of DISP employee allowed a month (IE. SSLINASTRETCH) in a straight line, IE. one day, that day is eligible for the bonus of presence.

    That is to say. Why the number of short leaves in a month is taken. If it's one and done minutes use is less than SSLINASTRETCH, then the day is eligible for the bonus of presence.

    But when I try to create the trigger I get error, PL/SQL: ORA-00907: missing a right parenthesis.

    You can not do in a trigger. Even if correct you this error of syntax, you will get the exception that I mentioned above.

    Oracle is a multi-user system. Other users can modify the same table that you use.

    So even if you could try to interview "all the records for this employee" some of them may be locked if other users access them. Also, an insert statement could try to insert two rows for an employee and the trigger could not have seen the other lines still.

    If you want to work with data SETS (all records for an employee), you must write the PL/SQL code that LOCKS all lines updated to prevent others to interfere.

    Then you make your operations but NOT in a trigger. Perform inserts and then use an UPDATE query to set this value.

    Then VALIDATE to unlock the lines.

  • Compare two rows in the same table

    Hi all

    I need to compare two rows in the same table, I don't know hoe to do it in pl/sql. Please help me on this.

    example:

    price of ro TR
    xya0001 AMA.7 12
    xya0003 ama6 14
    xya0004 AMA.7 16

    in table b is a unique value for each line, I need to compare the price column and see if the first value is less than or greater than the following value and, if there is more to put the corresponding value of br to a variable, and if it is less, put the corresponding value of the br to another variable. I don't know a method to do this, as I'm new to pl/sql. Please help me in this
    for data in(select tr,br,price, lag(price) over ( order by tr) newcol
    from yourtable)
    loop
    if nvl(data.newcol,0) > data.price then
    variable1:=data.br;
    else
    varable2:=data.br;
    end if;
    end loop;
    
  • update to column values (false) in a copy of the same table with the correct values

    Database is 10gr 2 - had a situation last night where someone changed inadvertently values of column on a couple of hundred thousand records with an incorrect value first thing in the morning and never let me know later in the day. My undo retention was not large enough to create a copy of the table as it was 7 hours comes back with a "insert in table_2 select * from table_1 to timestamp...» "query, so I restored the backup previous nights to another machine and it picked up at 07:00 (just before the hour, he made the change), created a dblink since the production database and created a copy of the table of the restored database.

    My first thought was to simply update the table of production with the correct values of the correct copy, using something like this:


    Update mnt.workorders
    Set approvalstat = (select b.approvalstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi)
    where exists (select *)
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi)

    It wasn't the exact syntax, but you get the idea, I wanted to put the incorrect values in x columns in the tables of production with the correct values of the copy of the table of the restored backup. Anyway, it was (or seem to) works, but I look at the process through OEM it was estimated 100 + hours with full table scans, so I killed him. I found myself just inserting (copy) the lines added to the production since the table copy by doing a select statement of the production table where < col_with_datestamp > is > = 07:00, truncate the table of production, then re insert the rows from now to correct the copy.

    Do a post-mortem today, I replay the scenario on the copy that I restored, trying to figure out a cleaner, a quicker way to do it, if the need arise again. I went and randomly changed some values in a column number (called "comappstat") in a copy of the table of production, and then thought that I would try the following resets the values of the correct table:

    Update (select a.comappstat, b.comappstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi - this is a PK column
    and a.comappstat! = b.comappstat)
    Set b.comappstat = a.comappstat

    Although I thought that the syntax is correct, I get an "ORA-00904: 'A'. '. ' COMAPPSTAT': invalid identifier ' to run this, I was trying to guess where the syntax was wrong here, then thought that perhaps having the subquery returns a single line would be cleaner and faster anyway, so I gave up on that and instead tried this:

    Update mnt.workorders_copy
    Set comappstat = (select distinct)
    a.comappstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi
    and a.comappstat! = b.comappstat)
    where a.comappstat! = b.comappstat
    and a.workordersoi = b.workordersoi

    The subquery executed on its own returns a single value 9, which is the correct value of the column in the table of the prod, and I want to replace the incorrect a '12' (I've updated the copy to change the value of the column comappstat to 12 everywhere where it was 9) However when I run the query again I get this error :

    ERROR on line 8:
    ORA-00904: "B". "" WORKORDERSOI ": invalid identifier

    First of all, I don't see why the update statement does not work (it's probably obvious, but I'm not)

    Secondly, it is the best approach for updating a column (or columns) that are incorrect, with the columns in the same table which are correct, or is there a better way?

    I would sooner update the table rather than delete or truncate then re insert, as it was a trigger for insert/update I had to disable it on the notice re and truncate the table unusable a demand so I was re insert.

    Thank you

    Hello

    First of all, after post 79, you need to know how to format your code.

    Your last request reads as follows:

    UPDATE
      mnt.workorders_copy
    SET
      comappstat =
      (
        SELECT DISTINCT
          a.comappstat
        FROM
          mnt.workorders a
        , mnt.workorders_copy b
        WHERE
          a.workordersoi    = b.workordersoi
          AND a.comappstat != b.comappstat
      )
    WHERE
      a.comappstat      != b.comappstat
      AND a.workordersoi = b.workordersoi
    

    This will not work for several reasons:
    The sub query allows you to define a and b and outside the breakets you can't refer to a or b.
    There is no link between the mnt.workorders_copy and the the update and the request of void.

    If you do this you should have something like this:

    UPDATE
      mnt.workorders     A      -- THIS IS THE TABLE YOU WANT TO UPDATE
    SET
      A.comappstat =
      (
        SELECT
          B.comappstat
        FROM
          mnt.workorders_copy B   -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      )
    WHERE
      EXISTS
      (
        SELECT
          B.comappstat
        FROM
          mnt.workorders_copy B
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      )
    

    Speed is not so good that you run the query to sub for each row in mnt.workorders
    Note it is condition in where. You need other wise, you will update the unchanged to null values.

    I wouold do it like this:

    UPDATE
      (
        SELECT
          A.workordersoi
          ,A.comappstat
          ,B.comappstat           comappstat_OLD
    
        FROM
          mnt.workorders        A      -- THIS IS THE TABLE YOU WANT TO UPDATE
          ,mnt.workorders_copy  B      -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES
    
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      ) C
    
    SET
      C.comappstat = comappstat_OLD
    ;
    

    This way you can test the subquery first and know exectly what will be updated.
    This was not a sub query that is executed for each line preformance should be better.

    Kind regards

    Peter

  • Insert data into the same table based on certain conditions

    Hello. I'm new to this forum.
    I have to write a stored procedure to insert data in a table MYTABLE say, having a structure like:

    Col1 Col2 Col3... TotalInstallments CurrentInstallment PaidAmount MonthYear
    I have to insert all the data that it is in the same table (MYTABLE) except change some fields based on certain conditions:

    1. if PaidAmount > 0 & & CurrentInstallment < TotalInstallment then

    CurrentInstallment = CurrentInstallment + 1

    2. in the field MonthYear I have data ex. 01/2012, 11/2012 formate(month/year)...

    So, I have to insert data by incrementing the month and year. for example:

    If currentdata is 11/2012 next data will be 12/2012

    But following will be 01, 2013
    I have to select all records that belongs to the previous month (across the field MonthYear) and put the audit on each record selected and insert data and then turns them into table (MYTABLE) even.

    How to achieve that?

    Thank you.

    978184 wrote:
    Hello. I'm new to this forum.
    I have to write a stored procedure to insert data in a table MYTABLE say, having a structure like:

    Col1 Col2 Col3... TotalInstallments CurrentInstallment PaidAmount MonthYear
    I have to insert all the data that it is in the same table (MYTABLE) except change some fields based on certain conditions:

    1. if PaidAmount > 0 & CurrentInstallment

    CurrentInstallment = CurrentInstallment + 1

    2. in the field MonthYear I have data ex. 01/2012, 11/2012 formate(month/year)...

    So, I have to insert data by incrementing the month and year. for example:

    If currentdata is 11/2012 next data will be 12/2012

    But following will be 01, 2013
    I have to select all records that belongs to the previous month (across the field MonthYear) and put the audit & on each of the selected data record and insert then turns them into table (MYTABLE).

    You can do this way:

    This is not tested, but if you can provide the example of table structure and data (IN create table and insert scripts), it can be put to the test.

    insert into your_table
    (col1, col2, col3...current_installment, month_field)
    select col1, col2, col3..,
           current_installment +
           case when paidamount > 0 and current_installment < total_installment then
            row_number() over (
                                partition by column1, column2,.. columnn      -->You may choose partition if you want the
                                                                              --Increment of Current_installment to reset after particular combination ends
                                order by primary_key        -->Order the Increment, you may choose to add more columns to order by
                              )
          else
            0                                               --> if condition is not met, then Add 0
          end curr_installment,
          add_months(to_date(month_field, 'MM/YYYY'), 1) nxt_month
      from your_table;
    
  • Update lines with the info from the other rows in the same Table.

    I'm trying to update the lines with the information of the same table. The table is loaded with information from a report that runs and there must be a new entry every month, but I would like to bring some of the info from the last month. This statement below works but updates all rows in the new load table and in my test case, I only did a few game only like 5 files need to get updates. It is an example of what I'm trying to do. If I add this (C2. COL_INVC_ID = C1. COL_INVC_ID) until the last "* where *" statement get an invalid identifier for 'C2 '. COL_INVC_ID ". So what I'm doing wrong here? How can I update only the lines where also in recent months run?

    Thanks in advance for any help!

    ------------
    Update OpenIssues OI1
    Together (OI1. NUM, OI1. Status, OI1. Code, OI1. LastModifiedDate) =
    (Select ios2. NUM, ios2. Status, ios2. Code, ios2. LastModifiedDate
    Of OpenIssues ios2
    Where OI2.num = OI1.num and ios2. TableLoadDate = TO_DATE (January 31, 2012 00:00:00 ',' ' the HH24: MI: SS DD/MM/YYYY)
    )
    Where and OI1. TableLoadDate = TO_DATE (February 29, 2012 00:00:00 ',' ' the HH24: MI: SS DD/MM/YYYY)
    ------------


    SQLMe

    As Frank suggested merger is much effective here, go...

      create table  temp
    as(
    select 1 eno, 1 amt , sysdate load_date from dual union all
    select 1 eno, 2 amt , add_months(sysdate,1) load_date from dual union all
    select 2 eno, 1 amt , sysdate load_date from dual union all
    select 2 eno, 2 amt , add_months(sysdate,1) load_date from dual
    );
    
    merge into temp t
    using (select eno, amt, load_date
             from temp
            where trunc(Load_Date) = TO_DATE('05/30/2012', 'MM/DD/YYYY')) s
    on ((s.eno = t.eno) and trunc(t.Load_Date) = TO_DATE('06/30/2012', 'MM/DD/YYYY'))
    when matched then
      update set t.amt = s.amt;
    commit;
    
    select * from temp;
    
  • Copy a few lines in the same table, but with different IDS

    Hi all
    I had this problem... I have a table with its pk (which is a sequence). With a statement select, I extract a few lines, and then I would record in the same table, but with IDS different (obviously eheheh).

    I don't know how to do...

    Thks for all help ;)


    p.s. I want to change some fields in lines before saving as well... don't know how do it more...

    example:

    ID NAME TYPE
    1 ferrari car
    2 cars lamborghini


    I'm trying to copy the second and changing its type in "BMW".

    I could result:

    1 ferrari car
    2 cars lamborghini
    3 bmw cars



    Thank you

    Assuming that your table is named cars_tb and the cars_seq of the sequence.

     insert into cars_tb
      select cars_seq.nextval, name, type
      from cars_tb
    

    This would overlap with any existing lines, but with a new id.

    If you want to duplicate a specific line and change a value, you could do something like:

     insert into cars_tb
      select cars_seq.nextval, name, 'BMW'
      from cars_tb
      where type = 'lamborghini'
    

    or better, use the PK

     insert into cars_tb
      select cars_seq.nextval, name, 'BMW'
      from cars_tb
      where id = 2
    
  • Copy the value1 to value2 column column in the same table

    Hi all

    If I want to update the values in column 2 stack with stack column. It's the same table 'Data_GU '.


    RACK_ID STACK STACK2
    S1009 706161522 S8322
    S1009 706168051 S8322
    S1009 706116417 S8322
    S1009 706126698 S8322

    I came with

    UPDATE DATA_GU C
    SET STACK2 =)
    SELECT battery
    OF DATA_GU B
    ) ;

    I have an error returns unique lines and more than one line... How to on this subject. Thank you guys.
    UPDATE DATA_GU
    SET STACK2 = STACK
    /
    

    SY.

  • comparing string values in the same table

    I have a table with ID (14 digit string values) starting with "A". Ex: A21849B1020792. There may be a different ID with the same substring 'B1020792' in the same table, example: A12349B1020792. If this happens, the ID of the last creation date of must be returned in the result. In other words, comparison is done on the same table. "In the example provided, say A12349B1020792 has the date of 1 January 2015 'and A21849B1020792 has date February 1, 2015", since A21849B1020792 has the most recent date, the result must contain only A21849B1020792.

    ID create_date

    ---                              ------------------

    A21849B1020792 02/01/2015

    A12349 B1020792 01/01/2015

    A12345B1234567 01/03/2015      

    A43567B1234567 01/04/2015      


    Here's the query I used:

    substr (a.id, 7) select sc, max (a.create_date) cd1

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A12349B1020792', 'A21849B1020792','A12345B1234567 ','A43567B1234567')

    Group of substr (a.id, 7);

    Result:

    ---------

    sc                    cd1

    ---                    ------

    B1020792 02/01/2015

    B1234567 04/01/2015

    There is one thing that I'm not able to do with my request, that is, be able to get real IDs list and not list of substrings. If I added a.id column in the select clause and the group by clause, the query includes both by substr (a.id, 7) and a.id and as a result, the query returns four lines as below:

    substr (a.id, 7) select sc, max (a.create_date) cd1, a.id ID

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A12349B1020792', 'A21849B1020792','A12345B1234567 ','A43567B1234567')

    Group by substr (a.id, 7), a.id.

    Result:

    ---------

    sc                    cd1                      ID

    ---                    ------                   ---------

    01/01/2015 A12349B1020792 B1020792

    B1020792 01/02/2015 A21849B1020792

    B1234567 01/03/2015 A12345B1234567

    B1234567 01/04/2015 A43567B1234567


    My goal is to retrieve a list of all the unique identifiers that have the later dates.


    ID:

    ---

    A21849B1020792

    A43567B1234567


    Thanks for your time in advance!

    Hello

    user11951344 wrote:

    I have a table with ID (14 digit string values) starting with "A". Ex: A21849B1020792. There may be a different ID with the same substring "B1020792" in the same table, example: A12349B1020792. If this is the case, the ID of the last creation date must be returned in the result. In other words, comparison is done on the same table. "In the example provided, say A12349B1020792 updated 1 January 2015 ' and A21849B1020792 a date February 1, 2015", as A21849B1020792 has the most recent date, the result should contain only the A21849B1020792.

    ID create_date

    ---                              ------------------

    A21849B1020792 02/01/2015

    A12349B1020792 01/01/2015

    A12345B1234567 03/01/2015

    A43567B1234567 01/04/2015

    Here's the query I used:

    substr (a.id, 7) select sc, max (a.create_date) cd1

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A21849B1020792', 'A12345B1234567', 'A12349B1020792', 'A43567B1234567')

    Group of substr (a.id, 7);

    Result:

    ---------

    sc                    cd1

    ---                    ------

    B1020792 02/01/2015

    B1234567 01/04/2015

    There is one thing that I am not able to do with my request, that is, the ability to retrieve the list of IDs real and not a list of substrings. If I added a.id column in the select clause and the group by clause, the query groups according to the two substr (a.id, 7) and a.id and as a result, the query returns four lines as below:

    substr (a.id, 7) select sc, max (a.create_date) cd1, a.id ID

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A21849B1020792', 'A12345B1234567', 'A12349B1020792', 'A43567B1234567')

    Group by substr (a.id, 7), a.id.

    Result:

    ---------

    sc                    cd1                      ID

    ---                    ------                   ---------

    B1020792 01/01/2015 A12349B1020792

    B1020792 02/01/2015 A21849B1020792

    B1234567 03/01/2015 A12345B1234567

    B1234567 01/04/2015 A43567B1234567

    My goal is to retrieve a list of all the unique identifiers that have the later dates.

    ID:

    ---

    A21849B1020792

    A43567B1234567

    Thanks for your time in advance!

    If it makes sense to treat the first 6 characters of the ID separately from the rest of the id in this problem, maybe it makes sense to store those two parts of the id in two different columns.  Relational databases work best when each column of each row contains 1 single piece of data (at most).  It is so fundamental to the design of table that he called the first normal form.

    Given that the two parts are stored in column 1, so you can something like this Request Top - N:

    WITH got_r_num AS

    (

    SELECT r.id

    r.create_date AS cd1

    , RANK () OVER (PARTITION OF SUBSTR (r.id, 7))

    ORDER BY r.create_date DESC

    ) AS r_num

    FROM table_x g - g for data values

    JOIN table_x r - r for related values

    ON SUBSTR (r.id, 7) = SUBSTR (g.id, 7)

    WHERE g.id IN ('A12349B1020792'

    , "A21849B1020792".

    , "A12345B1234567".

    , "A43567B1234567".

    )

    - AND g.id LIKE 'A %' - if necessary.   The above condition ensures already g.id start with "A".

    AND r.id LIKE 'a % '.

    )

    SELECT id, create_date

    OF got_r_num

    WHERE r_num = 1

    ;

    If you would care to post CREATE TABLE and INSERT instructions for the sample data, and then I could test this.

  • Insert select on the same table: possible without side effects?

    I have a very large table T1 containing millions of records. I need to treat its lines and create a few new lines based on selection.

    Table T1 contains events and one of them, with the code 100, is created by the further development of other events inside the table.

    My code is as follows:

    insert /*+append */ into T1 (code,...) values (100, c1,c2,...)
    select c1,c2... from T1 where (code=20 or code=10) and <other conditions>...
    
    

    as you can see I'm extract T1 lines to insert again in T1 with a different code and I use the direct path in order to get good performance.

    My fear is: choose is made from the same table I risk data loss? In general it is a good practice? Or is it better to create another table?

    Hello

    No I don't think that there may be loss of data. But that may depend on the behavior of the application and your where clause.

    I will explain how it is treated, so you can see if it's ok:

    1. the table is locked because of the insert add, (as)

    2 lines are read by select and make compatible from the State that was at the beginning of the query - 1.

    3 rows are inserted at the end, after the high-water line

    4 columns for new lines are sorted to be merged in the index

    5. high watermark is adjusted - visible new lines and lock is released

    Note that 2. and 3. occur at the same time: rows are inserted all read.

    Note that anyone can choose in the table during the operation - they see the changes committed only - if the State 1.

    all other DML are waiting for the lock being released, and will see new ranks and then

    If you have things that prevent the direct-path insert, append the hint will be ignored. So, if you must rely on close to 1. then the best lock explicitly with table lock. But I don't think that you need.

    Kind regards

    Franck.

  • Help with career within the same table and find the relevant rank.

    HI all the gurus

    Pls help me out here... I need to implement some which is dependent on SUPERIOR record following found regarding one earlier. Some examples of data.

    create table SOR_OFF (OFF_ID, OFFS_ID number, REPORT number, CON_DATE number date, STATE varchar2 (20));

    REM INSERTING into  SOR_OFF
    SET DEFINE OFF;
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (987,349,30658,to_date('12-SEP-04','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (988,349,30658,to_date('29-DEC-98','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (990,349,30658,to_date('29-JUL-96','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (991,350,30658,to_date('27-NOV-90','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (992,352,30658,to_date('04-OCT-91','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (993,353,30658,to_date('12-JUN-95','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (994,353,30658,to_date('21-NOV-83','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (995,355,30658,to_date('21-APR-94','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (996,356,27250,to_date('23-SEP-94','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (997,357,30658,to_date('15-MAY-95','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (998,358,30658,to_date('13-JAN-93','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (999,358,30658,to_date('13-MAR-93','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1000,359,30658,to_date('17-DEC-96','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1003,360,30658,to_date('22-JUN-92','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1004,361,30658,to_date('15-FEB-94','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1006,362,30658,to_date('26-JUL-94','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1007,364,30658,to_date('01-JUL-92','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1009,365,30658,to_date('20-MAY-99','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1010,365,30658,to_date('01-JUL-99','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1011,366,30658,to_date('18-JUN-84','DD-MON-RR'),'Deleted');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1012,366,30658,to_date('15-JUL-94','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1013,366,30658,to_date('15-JUL-94','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1014,367,30658,to_date('07-NOV-94','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1015,368,30658,to_date('29-MAY-90','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1016,369,30658,to_date('10-SEP-92','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1020,370,30658,to_date('07-JUL-92','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1026,372,30658,to_date('23-JUL-93','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1027,373,30658,to_date('30-OCT-96','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1030,375,30658,to_date('03-OCT-91','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1034,376,30658,to_date('20-APR-95','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1037,378,30658,to_date('07-APR-92','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1039,379,30658,to_date('26-JAN-94','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1040,380,30658,to_date('12-MAY-93','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1041,381,30658,to_date('08-JAN-93','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1042,382,13428,to_date('27-JAN-92','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1043,383,30658,to_date('19-APR-91','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1044,384,30658,to_date('17-DEC-54','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1045,385,27884,to_date('03-APR-90','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1046,386,28480,to_date('01-DEC-92','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1048,388,30658,to_date('18-AUG-92','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1050,389,3894,to_date('26-AUG-88','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1051,389,30658,to_date('09-APR-96','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1053,391,30658,to_date('30-NOV-90','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1054,392,30658,to_date('27-MAY-93','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1055,393,3894,to_date('05-JUN-91','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1056,394,30658,to_date('29-MAY-96','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1057,395,3894,to_date('15-JUL-94','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1058,396,30658,to_date('22-FEB-91','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1061,398,30658,to_date('14-MAR-90','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,CON_DATE,STATUS) values (1062,398,30658,to_date('14-MAR-90','DD-MON-RR'),'Active');
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (52810,37334,27250,'ACTIVE',to_date('25-JUL-01','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (52811,37334,27250,'ACTIVE',to_date('23-NOV-08','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (21648,17315,27250,'Deleted',to_date('02-JAN-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (24740,17315,27250,'ACTIVE',to_date('05-JAN-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (8622,6410,27250,'Active',to_date('26-JUN-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (44079,6410,27250,'ACTIVE',to_date('27-OCT-08','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (54828,38266,13428,'ACTIVE',to_date('31-JUL-96','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55278,38266,13428,'ACTIVE',to_date('10-SEP-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55279,38266,13428,'ACTIVE',to_date('13-NOV-01','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (48172,34748,17442,'ACTIVE',to_date('03-SEP-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (48173,34748,17442,'ACTIVE',to_date('01-APR-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (45319,33194,9950,'ACTIVE',to_date('03-APR-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (45320,33194,9950,'ACTIVE',to_date('21-FEB-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (46803,34029,30862,'ACTIVE',to_date('05-MAY-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (46804,34029,30862,'ACTIVE',to_date('26-OCT-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (53886,34029,30658,'ACTIVE',to_date('18-NOV-09','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (13479,11608,14966,'Active',to_date('16-NOV-99','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (13480,11608,14966,'Active',to_date('01-JAN-01','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (60251,40687,27250,'ACTIVE',to_date('23-JAN-09','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (60252,40687,27250,'ACTIVE',to_date('14-JUL-09','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (17454,14278,604,'Active',to_date('10-AUG-99','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (17455,14278,1232,'Active',to_date('27-OCT-03','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (52438,37084,27250,'ACTIVE',to_date('23-JUL-03','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (52648,37084,27250,'ACTIVE',to_date('17-FEB-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (20653,16456,27250,'Deleted',to_date('02-JUN-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (31000,16456,0,'Deleted',null);
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (38241,16456,27250,'ACTIVE',to_date('28-APR-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (54130,37980,1232,'ACTIVE',to_date('08-MAR-00','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (56129,37980,1232,'ACTIVE',to_date('07-AUG-08','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55025,38388,30622,'ACTIVE',to_date('06-DEC-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55032,38388,30622,'ACTIVE',to_date('01-DEC-10','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55517,38657,27884,'ACTIVE',to_date('04-FEB-10','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55518,38657,27884,'ACTIVE',to_date('17-AUG-09','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55519,38657,27884,'ACTIVE',to_date('21-JUL-09','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (44764,32871,12408,'ACTIVE',to_date('18-JUN-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (44765,32871,12408,'ACTIVE',to_date('16-JUN-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (44766,32871,12408,'ACTIVE',to_date('16-JUN-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (19076,15174,27250,'ACTIVE',to_date('02-NOV-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (50173,15174,1232,'ACTIVE',to_date('16-SEP-08','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (45046,33005,27250,'ACTIVE',to_date('03-SEP-92','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (45160,33005,27250,'ACTIVE',to_date('08-FEB-01','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (45161,33005,27250,'ACTIVE',to_date('06-NOV-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (44118,32387,27250,'ACTIVE',to_date('22-MAR-96','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (44119,32387,9950,'ACTIVE',to_date('30-DEC-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (44120,32387,9950,'ACTIVE',to_date('28-SEP-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (48418,34888,19586,'ACTIVE',to_date('02-MAR-90','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (48419,34888,28480,'ACTIVE',to_date('18-DEC-07','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (48420,34888,28480,'ACTIVE',to_date('24-AUG-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (43307,31893,29598,'ACTIVE',to_date('26-APR-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (43437,31893,9950,'ACTIVE',to_date('20-SEP-07','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (53612,37738,13428,'ACTIVE',to_date('28-JUN-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (53613,37738,15208,'ACTIVE',to_date('15-DEC-08','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (21555,17241,13428,'ACTIVE',to_date('11-JUN-99','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (21556,17241,13428,'ACTIVE',to_date('02-JAN-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (41336,30685,14966,'ACTIVE',to_date('07-OCT-03','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (42363,30685,9950,'ACTIVE',to_date('20-NOV-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (50926,36355,30862,'ACTIVE',to_date('13-DEC-07','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (50928,36355,30862,'ACTIVE',to_date('13-SEP-07','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (25520,20471,27250,'ACTIVE',to_date('06-JUN-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (25521,20471,0,'ACTIVE',to_date('31-AUG-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (2035,1069,30658,'Active',to_date('29-JAN-92','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (36762,1069,9950,'ACTIVE',to_date('16-MAY-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (36763,1069,9950,'ACTIVE',to_date('17-AUG-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (29807,23548,18458,'ACTIVE',to_date('18-AUG-00','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (29826,23548,17868,'ACTIVE',to_date('13-AUG-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (12818,10852,1232,'Active',to_date('01-JUN-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (12988,10852,1232,'Active',to_date('01-JUL-00','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (44287,32502,27884,'ACTIVE',to_date('10-JAN-08','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (44917,32502,9950,'ACTIVE',to_date('09-JUL-08','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (14430,12464,15070,'Active',to_date('03-APR-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (14431,12464,30658,'Active',to_date('08-NOV-89','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (42691,12464,30622,'ACTIVE',to_date('18-JAN-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (21608,17278,14966,'ACTIVE',to_date('03-AUG-00','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (25145,17278,14966,'ACTIVE',to_date('01-NOV-00','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (54918,38323,17868,'ACTIVE',to_date('21-MAR-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55607,38323,17868,'ACTIVE',to_date('22-APR-10','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (28304,22497,1232,'ACTIVE',to_date('29-NOV-01','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (40755,22497,1232,'ACTIVE',to_date('13-DEC-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (13239,11318,19002,'Deleted',to_date('01-APR-99','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (13240,11318,19002,'Active',to_date('01-JAN-00','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (54317,38064,14966,'ACTIVE',to_date('01-DEC-99','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (54318,38064,30862,'ACTIVE',to_date('14-OCT-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (60404,38064,30658,'ACTIVE',to_date('31-AUG-11','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (60405,38064,30658,'ACTIVE',to_date('31-AUG-11','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (52800,37327,27250,'ACTIVE',to_date('27-JUN-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (52801,37327,27250,'ACTIVE',to_date('27-JUN-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (52802,37327,27250,'ACTIVE',to_date('19-DEC-99','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (41154,30599,27250,'ACTIVE',to_date('02-APR-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (46115,30599,27250,'ACTIVE',to_date('15-SEP-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (48532,34983,1232,'ACTIVE',to_date('16-SEP-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (48533,34983,1232,'ACTIVE',to_date('16-SEP-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (26868,21438,1232,'ACTIVE',to_date('13-JAN-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (26909,21438,1232,'ACTIVE',to_date('13-DEC-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (54646,38177,28480,'ACTIVE',to_date('02-DEC-99','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (54647,38177,28480,'Deleted',null);
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (54648,38177,28480,'ACTIVE',to_date('01-NOV-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (26924,21471,10672,'ACTIVE',to_date('16-JAN-97','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (27385,21471,10672,'ACTIVE',to_date('12-NOV-97','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (27404,21471,3894,'ACTIVE',to_date('02-MAR-01','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (40329,30063,28480,'ACTIVE',to_date('07-OCT-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (40407,30063,28480,'ACTIVE',to_date('27-OCT-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (27949,22235,27250,'ACTIVE',to_date('07-JUL-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (27950,22235,27250,'ACTIVE',to_date('07-JUL-03','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (32387,25414,19032,'ACTIVE',to_date('18-APR-00','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (46214,25414,19032,'ACTIVE',to_date('18-APR-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (32226,25340,30658,'ACTIVE',to_date('25-MAY-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (33363,25340,27884,'ACTIVE',to_date('11-SEP-99','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (33364,25340,27884,'ACTIVE',to_date('08-FEB-01','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55789,38840,1830,'ACTIVE',to_date('22-MAR-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55790,38840,1830,'ACTIVE',to_date('22-MAR-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (55792,38840,1830,'ACTIVE',to_date('20-MAR-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (1976,1026,30658,'Active',to_date('21-JUN-94','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (47881,1026,1232,'ACTIVE',to_date('25-SEP-09','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (47882,1026,1232,'ACTIVE',to_date('21-JUN-04','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (13820,11900,27250,'Active',to_date('15-MAY-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (35519,11900,27250,'ACTIVE',to_date('18-JAN-99','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (35520,11900,27250,'ACTIVE',to_date('14-AUG-00','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (35521,11900,30658,'ACTIVE',to_date('03-DEC-02','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (35524,11900,30658,'ACTIVE',to_date('21-MAR-06','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (35525,11900,27250,'ACTIVE',to_date('29-AUG-01','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (26168,20977,27250,'ACTIVE',to_date('24-OCT-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (27644,20977,27250,'Deleted',to_date('29-OCT-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (27764,20977,27250,'Deleted',to_date('28-OCT-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (50681,20977,27250,'ACTIVE',to_date('28-OCT-05','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (49856,35737,27250,'ACTIVE',to_date('03-DEC-97','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (49858,35737,27250,'ACTIVE',to_date('19-JUL-07','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (41260,30649,27250,'ACTIVE',to_date('01-JUL-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (41261,30649,27250,'ACTIVE',to_date('01-JUN-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (8290,6012,14966,'Active',to_date('16-OCT-98','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (8291,6012,14966,'Active',to_date('24-FEB-99','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (49978,35835,9950,'ACTIVE',to_date('10-SEP-01','DD-MON-RR'));
    Insert into  SOR_OFF (OFF_ID,OFFS_ID,STATE,STATUS,CON_DATE) values (49979,35835,9950,'ACTIVE',to_date('31-MAY-06','DD-MON-RR'));
    

    What I want is less than

    -Search for a line more low which is CON_DATE > = to_date ('01-NOV-1998', ' MON-DD-YYYY "") AND STATE = 30658 and get the second row whose state = 30658 but having separate con_date

                               or CON_DATE = > = to_date (November 1, 1997 ',' MON-DD-YYYY "") AND STATE <>30658 & get the second row including State = 30658 but having separate con_date

    and lower (status) = 'active '.


    and get another line that extends beyond the found line, but having separate con_date (no operation of the same day.)

    I tried to do it with and then attach it again with the same table, but I don't get different results...

    Please advise.

    Hello

    n_shah18 wrote:

    NO Frank

    Thanks for trying.

    First find a line that corresponds

    ((CON_DATE > = to_date (1er novembre 1998 ', ' MON-DD-YYYY ") AND STATE = 30658))

    or (CON_DATE > = to_date (November 1, 1997 ',' MON-DD-YYYY "") AND STATE <> 30658))


    8 second get/check the following line immediately for offs_id even that has different con_date, that is superior to prev con_date but State should be 3065


    If offs_id found then return else throw line...


       


    Thus, in addition to the conditions that I listed previously, there must be a line with the same offs_id, which has a con_date later and the State concerned; is this fair?

    You can use a self-join to see if there is such an extra line:

    WITH params AS

    (

    SELECT TO_DATE (November 1, 1998 ', 'DD-Mon-YYYY') AS later_threshold_date

    AS target_state 30658

    11900 AS target_offs_id

    OF the double

    )

    SELECT s.offs_id

    OF s sor_off

    JOIN params p ON s.offs_id = p.target_offs_id

    AND ((s.con_date > = p.later_threshold_date))

    AND s.state = p.target_state

    )

    OR (s.con_date > = ADD_MONTHS (p.later_threshold_date, 12))

    AND s.state <> p.target_state

    )

    )

    JOIN sor_off ON s2.offs_id = s.offs_id s2

    AND s2.con_date > s.con_date

    AND s2.state = p.target_state

    GROUP BY s.offs_id

    ;

    The only difference between this and the previous solution is the last join, in other words, the 3 lines of code just before the GROUP BY clause.

  • How to update columns with the value of other lines in the same table

    Hello

    I use Oracle 11.2, I'd use SQL statements to update a column based on values in other rows in the same table. Here are the details:

    create table TB_test (number 4 myId, crtTs date, date of MDPU);

    insert into tb_test (1, to_date ('20110101', 'YYYYMMDD'), null);
    insert into tb_test (1, to_date ('20110201', 'YYYYMMDD'), null);
    insert into tb_test (1, to_date ('20110301', 'YYYYMMDD'), null);
    insert into tb_test (2, to_date ('20110901', 'YYYYMMDD'), null);
    insert into tb_test (2, to_date ('20110902', 'YYYYMMDD'), null);

    After you run the SQL code, I would like to have the following result:

    1, 20110101, 20110201
    1, 20110201, 20110301
    1, 20110301, null
    2, 20110901, 20110902
    2, 20110902, null

    Thanks for your suggestion.

    I guess you need this, otherwise please explain logic correctly:

    SQL> merge into tb_test t
      2  using (
      3    select rowid as rid
      4         , lead(crtts) over(partition by myid order by crtts) as updts
      5    from tb_test
      6  ) v
      7  on (t.rowid = v.rid)
      8  when matched then update
      9   set t.updts = v.updts
     10  ;
    
    5 rows merged.
    
    SQL> select * from tb_test order by 1,2;
    
          MYID CRTTS     UPDTS
    ---------- --------- ---------
             1 01-JAN-11 01-FEB-11
             1 01-FEB-11 01-MAR-11
             1 01-MAR-11
             2 01-SEP-11 02-SEP-11
             2 02-SEP-11
    
  • Name of the file and the measure in the same table?

    Hello

    I wrote the following VI which opens each image file in a folder and measure a certain size on the image. He then puts the result in a table.

    The table has a column and N lines since I N images in my folder. How can I change this VI so that it puts the name of the file in the same table as well as the measurement?

    I want the table to look like:

    File1 measurement1

    File2 GCA2

    ...

    and so on.

    Currently, it just shows

    measurement1

    GCA2

    ....

    and so on.

    The VI are:

    You cannot use the Table Express. Like the properties page says: this is for digital data. You will need to use a bit of real LabVIEW to create the table. A table is simply a string 2D array. Convert the digital chain, build an array of 1 d of the filename and numberic strings and use a shift register to build a 2D array. Something like the code below.

  • Component used to self referencing the same table?

    Hi all.. I'm new to ADF... I have to implement article comment in my application... I don't have only one table to store comments and responses... observations and replicas are identified by a column 'comment_type' that stores the 'R' for the answers and 'C' for the comments... so I have to use the same table again and again to find out if a comment is to have an answer... so which is the best method to apply this and which component is appropriate for this implementation?

    Any help would be great-Jey

    User, tell us your version of Jdev, please!

    A tree will represent you the best data. In your car, you use a self-join view object as described here http://www.oracle.com/technetwork/developer-tools/adf/learnmore/32-tree-table-from-single-vo-169174.pdf

    Timo

  • place a select query calculation in a different column in the same table

    How can I put my calculation result in a column named within the same table?

    I have a table called: dgpercentagedatachart

    I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage

    In the query, I gave the result the Alias of the cal

    What I want is to put this result in my application or my calculation (in percentage) in my column "percent" on my table of dgpercentagedatachart vacuum.

    How can I configure this syntax?

    This is the select query, I came with:

    Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.

    100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal

    of dgpercentagedatachart;

    Here are the results:

    CAL lowestfeederrating Totalcecrating

    8,978 7.48166666666666666666666666666666666667 120

    30.951 25.7925 120

    5.04                         120                          4.2

    Hello

    2685870 wrote:

    How can I put my calculation result in a column named within the same table?

    I have a table called: dgpercentagedatachart

    I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage

    In the query, I gave the result the Alias of the cal

    What I want is to put this result in my application or my calculation (in percentage) in my empty column '%' on my table of dgpercentagedatachart .

    How can I configure this syntax?

    This is the select query, I came with:

    Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.

    100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal

    of dgpercentagedatachart;

    Here are the results:

    CAL lowestfeederrating Totalcecrating

    8,978 7.48166666666666666666666666666666666667 120

    30.951 25.7925 120

    5.04                         120                          4.2

    To change an existing column in a table, you can use the UPDATE or MERGE, instructions like this:

    UPDATE dgpercentagedatachart

    Percentage of VALUE = 100,00 * totalcecrating

    / lowestfeederrating

    ;

    Noramlly, tables is not redundant columns like this.  If percent can always be calculated from other columns, then it is probably better to calculate at run time and store it in the database, where you will have to be updated each time the columns it depends on change.  You can use a view to avoid having to encode them the calculation.

    If you really don't want a column that can be calculated in the same lines other columns, then use a virtual column (if you use Oracle 11 or higher).

    I hope that answers your question.

    If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.

    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • Make a column based on another value of the column in the same table

    JDev 11.1.1.6.0

    It may be a silly question but I'm stuck

    I need to conditionally return a column that said Condition is as if the value in the other column of the same table B is equal to F. I should make A column only when this condition is met. I tried the following code:

    < af:column sortProperty = "PhoneNumber1."
    sortable = "false".
    headerText = "#{bindings." A.hints.PhoneNumber1.label}.
    ID = "c146.
    rendering = "#{rank." PhoneNumber1ResponseFlag eq 'F'} ">"
    < af:outputText value = "#{rank." PhoneNumber1}.
    ID = "ot130" / >
    < / af:column >
    < af:column sortProperty = "PhoneNumber1ResponseFlag."
    sortable = "false".
    headerText = "#{bindings." B.hints.PhoneNumber1ResponseFlag.label}.
    ID = "c80" rendered = "true" >
    < af:outputText value = "#{rank." PhoneNumber1ResponseFlag}.
    ID = "ot129" / >
    < / af:column >

    The data presented in the table for the PhoneNumber1ResponseFlag column are F. Still my condition does not work.

    Well, I've finally sorted it myself by managed bean.

    Here are the steps I followed:

    1. Wrote a new bean managed.
    2. Added a Boolean variable called flag and made to true when the "'PhoneNumber1ResponseFlag ' current line attribute is equal to F."
    3. Changing the property made column on this indicator.

Maybe you are looking for

  • Photosmart 6510: AirPrint

    I'm used to be able to print from my iPhone.  Since I installed a new router that I have not been able to print from my iPhone.  When I hit the key apps I get "Server Conection error:-1.»  problem connecting to the server. The printer is connected to

  • No bar progression in Photos

    Why is there not a bar of progression in Photos? I did a fairly major export and would want to know how it progresses, and when he was finished successfully. Now, I know you must have Photos related to Notifications for a report, but otherwise, there

  • A10: You are looking for a physical formatting software

    HelloI am looking for software to do a physical format for my HARD drive. I have a Satellite A10.I want to erase all sector and create a new one because I have a serieus probem.If anyone knows where I can find it please help! Thank you

  • HP DesignJet Z6200 plotter ink error - ink appearing

    I print the cards on a large scale on a plotter HP Designjet Z6200 and ink blots are appearing on the side. While the tasks are not printing itself, it always indicates an error. In addition, on diagnostics test print only, some of them does not appe

  • Computer crashes when tried to wake mode "Eve" in Vista

    My computer completely froze when I tried to wake him from sleep.  The button on the tower was blinking 'blue', but it was too frozen - provide no response from the computer.  In the end, I had to pull on the power cord.  What gives?  I am not given