Find records based on their insertion order

Hi to all,
Is there any way I can find records based on their insertion order.
Like i inserted 5 records, can I find fifth record based on that insertion order?
Advance thanks for your inputs
Regards
Karthik

Not without adding some kind of sequencing mechanism to your inserts.
You could use sequence numbers, or for more robustness, insert timestamps alongside your inserts.
Triggers will help you to acheive this.

Similar Messages

  • Java executeBatch() - Problem in INSERT (Order of  records not maintained)

    When we make a executeBatch() . And when the use
    select * from DUMMY_FILE_S order by ROWID
    or
    select * from DUMMY_FILE_SThe rows returned are in different order.( that is its not in the order what is inserted actually)
    And this happens once in a While.
    This is will happen only if we try many times also So please try with many INSERTs
    Please find the Java Code and the Insert SQL.
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.io.*;
    import java.sql.DriverManager;
    public class warranty_dummy
         public static void main(String args[])
                String FILENAME = "D:/data.sql";
                Connection conn = null;
                //String db_file_name_prefix = "@localhost:1531:xxxx_y14";
                   try {
                       Class.forName("oracle.jdbc.OracleDriver").newInstance();
                       // DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
                        catch (ClassNotFoundException e) {
                               e.printStackTrace();
                               //System.out.println("INSIDE class forname :"+ e.getStackTrace());
                   }catch(Exception e){
                        e.printStackTrace();
             try{
                    conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1531:yyyy_xxxx","my_user","password");
                 Statement stmt = conn.createStatement();
                   BufferedReader in = new BufferedReader(new FileReader(FILENAME));
                 String line = in.readLine();
                 System.out.println("Line " + line);
                  while(line != null) {
                 System.out.println("Line 1" + line);
                   stmt.addBatch(line);
                 line = in.readLine();
                 System.out.println("Outside While");
                 in.close();
                 int iarray[] = stmt.executeBatch();
                 System.out.println("Count" + iarray.length);
                 catch (Exception e ){
                         System.out.println("Error attempting to store results for batch " + e.getMessage());
                     } finally {
                         try {
                             conn.commit();
                             conn.close();
                         } catch (Exception se) {
                             System.out.println("Error attempting to store results for batch "+ se.getMessage());
    }SQL Data sample
    INSERT INTO DUMMY_FILE_S (FILE_NO,S_NO) values (44444,'123456789')
    INSERT INTO DUMMY_FILE_S (FILE_NO,S_NO) values (44444,'567891234')
    INSERT INTO DUMMY_FILE_S (FILE_NO,S_NO) values (44444,'333333333')
    INSERT INTO DUMMY_FILE_S (FILE_NO,S_NO) values (44444,'323232323')

    Thanks for your prompt reply.
    If we even use ORDER BY clause, we still don't get the records in the order what we inserted.
    And we see that the problem is in smt.executeBatch(); is not inserting the records the way its inserted
    For Example.
    if we insert
    INSERT INTO MyTable (SERIAL_NUMBER, DESCRIPTION ) VALUES (1,"test1");
    INSERT INTO MyTable (SERIAL_NUMBER, DESCRIPTION ) VALUES (2,"test2");
    INSERT INTO MyTable (SERIAL_NUMBER, DESCRIPTION ) VALUES (3,"test3");
    INSERT INTO MyTable (SERIAL_NUMBER, DESCRIPTION ) VALUES (4,"test4");Note : (Using smt.executeBatch();)
    After that when we use
    Select * from MyTable ORDER BY ROWIDFor some time we get the result of the query as ( In the order we Insert )
    SERIAL_NUMBER, DESCRIPTION
    ==========================
    1,test1
    2,test2
    3,test3
    4,test4And For some time we get the result of the query as ( We don't get the records in the order we Insert )
    SERIAL_NUMBER, DESCRIPTION
    ==========================
    1,test1
    3,test3
    2,test2
    4,test4Is there any work around for this?
    Thanks in advance

  • Insert Records Based on User requirement

    Hi,
    I want to Create a set of records based on the user input defined on run time.
    According to my present query i am able to create records which is predefined in 'NoOfRows' variable . Hence when i click on this button, by default 2 rows are inserted in my page.
    My requirement is to get the 'NoOfRows' from user, hence i added an input text in my Jsf page which gets the value from user and based on that the rows will be inserted. But i coudn't pass my Rich input text value to this variable. i.e 'NoOfRows'. How is this possible to pass my input text value which is defined in my bean to the java class defined in Application Moldule?
    This is my code written in AppModuleImpl.java
    public void insertDefaultRows(){
    ViewObjectImpl Lines = this.getEmpView1();
    Lines.executeEmptyRowSet();
    int NoOfRows=2;
    oracle.jbo.server.ViewRowImpl emptyRow;
    for (int i=0; i < noOfRows;i++){
    emptyRow = (oracle.jbo.server.ViewRowImpl)Lines.createRow();
    emptyRow.setNewRowState(oracle.jbo.Row.STATUS_INITIALIZED);
    Lines.insertRow(emptyRow);
    This is my backing bean defined for the input text
    public void setIt11(RichInputText it11) {
    this.it11 = it11;
    public RichInputText getIt11() {
    return it11;
    Hope I'm clear. Any help?

    First of all you have to change the signature of the method in the AM to
    public void insertDefaultRows(int num){
      if (num <= 0)
        return;
      ViewObjectImpl Lines = this.getEmpView1();
      Lines.executeEmptyRowSet();
      int NoOfRows=num;
      oracle.jbo.server.ViewRowImpl emptyRow;
      for (int i=0; i < noOfRows;i++){
        emptyRow = (oracle.jbo.server.ViewRowImpl)Lines.createRow();
        emptyRow.setNewRowState(oracle.jbo.Row.STATUS_INITIALIZED);
       Lines.insertRow(emptyRow);
    }then you expose this method to the client interface of the AM. This makes it available in the data control.
    Next you should add a variable in the executable section of the bindings of the page.
    1) open the bindings of the page
    2) right click on the variables in the executables section and choose 'Insert Inside Variables'->'variable'
    3) in the dialog set a name e.g. noOfRows with type java.lang.Integer
    4) click the green '+' sign in the Bindings section, select AattributeValues, cklick OK
    5) select 'variables' as datasource and 'noOfRows' as attribute
    This will create a variable of type integer in the bindings of the page. This can be used to store the value of the inputText component. For this select the inputText in your page and in the property inspector add
    #{bindings.noOfRows1.inputValue}to the value property. This will transfer the input from the inputText to the variable you created.
    Now open the DataControll and drag the method onto the page and drop it as a button. You then get a dialog where you see the 'num' parameter of the method. In the value field you write the binding you used to store the value from the inputText (#{bindings.noOfRows1.inputValue}).
    Last thing to do is to set the autoSubmit property of the inputText to true.
    This will pass the value from the inputtext to the method.
    Timo
    Edited by: Timo Hahn on 20.03.2013 13:48
    Oh, and you can remove the binding of the inputText to the bean as this is not needed!

  • Numbering images based on their position in a document

    Hello,
    Is it possible to give images an automatic number based on their position in a document.
    For example: I have 3 images A, B and C. I place them in order A = 1, B = 2 and C = 3.
    Then I change my mind and I move image B to the front.
    I want the numbers to change so that B=1, A=2 and C=3, but this doesn't happen.
    I have the same problem if I insert an image D between A and B. I want the numbers to change to A=1, D=2,B=3 and C=4, but the number of the new image just becomes 4.
    I can't find a solution for this problem. Can anyone help me out?
    Thanks,
    BB

    A paragraph style with the Numbering option turned on and this applied to the Figure text would be as close as you can get to a solution. It is not quite as thorough as FrameMaker in this regard, but it isn't bad for general document construction. Once you get into the hundreds and thousands of pages of illustrated figures, this becomes a lot of time and human management.

  • Select records based on 1 field have either of 2 values

    Good afternoon,
    II have 2 tables, Account and Order, it's a one to many where 1 account can have many orders. I'm trying to pull the records where the account has orders that have a status of Completed or Quoted. I know I'm not explaining well so hopefully the example below will help.
    Account A has 3 orders, all of them are completed.
    Account B has 5 orders, 2 of them are completed, and 3 of them are quoted.
    Account C has 2 orders, all of them are quoted.
    I only want Account B to show up in my report. That is, I only want accounts that have both completed and quoted orders
    I've tried various record selections but because the status field on a single order can only have one value I'm not sure how to get the results that I need.
    Any help would be greatly appreciated.
    Jeannette

    hi Jeanette,
    for this you may either have to write a report with a Command based object with a subselect and a WHERE IN clause.
    there's an easier way using a Group Selection formula though...the disadvantage of this method is that this doesn't filter those records out at the database which could be a problem if you're dealing with 100's of thousands of records. if that's the case, then use the method mentioned at the top.
    For a Group Selection method try the following:
    1) create a Group on the Accountfield
    2) create a formula called Completed that reads something like
    if = 'Completed' then 1
    3) create another formula called 'Quoted' that reads something like
    if = 'Quoted' then 1
    4) put these fields on the report and put a Summary on them at the Account Group level
    5) go into the Group Selection Formula and find your group level summaries and create a formula similar to
    Sum(AccountGroup, @Completed) > 0 and Sum(AccountGroup,@Quoted) > 1
    This will bring back only Accounts with both completed and quoted records.
    cheers,
    jamie

  • Select records based on the closest given time

    Dear SQL gurus,
    I have a table T1:
    Name Null? Type
    ID NOT NULL NUMBER(5)
    MOMENT NOT NULL DATE [DD.MM.YYYY HH24:MI]
    MEASUREMENT NOT NULL NUMBER(8,3)
    Example (ID, MOMENT, MEASUREMENT)
    -- START OF EXAMPLE --
    9380 18.11.2000 03:45 17.6
    9380 18.11.2000 04:30 17.3
    9380 18.11.2000 05:45 16.8
    9380 18.11.2000 06:15 16.8
    9380 18.11.2000 07:00 16.2
    9380 18.11.2000 07:30 16.2
    9380 18.11.2000 08:15 16
    9380 18.11.2000 08:45 15.7
    9380 18.11.2000 09:30 15.4
    9380 18.11.2000 10:00 15.4
    9380 18.11.2000 11:15 15.4
    9380 18.11.2000 11:45 15.4
    9380 18.11.2000 12:30 15.4
    9380 18.11.2000 13:00 15.4
    9380 18.11.2000 13:45 15.4
    --- END OF EXAMPLE --
    How to select records based on the:
    - time period specified by the day only [DD.MM.YYYY] - CONDITION 1
    - with values for 6AM only, and if not available, with values closest to 6AM - CONDITION 2
    (if the time gap in MOMENT field is too big, lets say > 5h then choose the average between the value before 6AM (ex. 4:15AM) and the value after the 6AM (ex. 9:45AM))
    CONDITION 1 (something like): moment between '01.01.2005' and '31.12.2004' - this is OK
    CONDITION 2: I do not know how to formulate, especially if 6AM value is not availabe, and I have to find the closest available value, or get the avergae from the two adjacent values.
    Maybe cursor magic??? Thanks a lot for your help.
    Rado

    About condition two, would the following select be of use to you? Picking the first record could be achived by rownum, analytic function, etc.
    WITH t1 AS (SELECT 9380 id, TO_DATE('18.11.2000 03:45', 'dd.mm.yyyy hh24:mi') moment,  17.6 measurement
                  FROM dual
                 UNION 
                SELECT 9380 id, TO_DATE('18.11.2000 04:30', 'dd.mm.yyyy hh24:mi') moment,  17.3 measurement
                  FROM dual
                 UNION
                SELECT 9380 id, TO_DATE('18.11.2000 05:45', 'dd.mm.yyyy hh24:mi') moment,  16.8 measurement
                  FROM dual
                 UNION
                SELECT 9380 id, TO_DATE('18.11.2000 06:15', 'dd.mm.yyyy hh24:mi') moment,  16.8 measurement
                  FROM dual
    SELECT id, moment, measurement, diff
      FROM (SELECT id, moment, measurement,
                   moment - TO_DATE(TO_CHAR(moment, 'dd.mm.yyyy ') || '06:00', 'dd.mm.yyyy hh24:mi') diff
              FROM t1
    ORDER BY abs(diff) asc, SIGN(diff) desc;
      C.

  • How to add extra per day records based on maximum occurances in the week.

    Hello,
    I need to add extra records based on maximum occurances on a day in a week.
    For example, the result of the query shows that maximum occuances in a week 0 is 3 on so I need to add empty records in each day in that week.
    SQL QUERY:
    with  numbers as (
    SELECT ROWNUM N FROM dual 
      CONNECT BY LEVEL <=35
    ),months as (
    SELECT     ADD_MONTHS('01-JUN-10',n-1) AS current_month,
         TO_CHAR(ADD_MONTHS('01-JUN-10',n-1),'fmMonth-YYYY') AS current_month_label
    FROM numbers
    WHERE ADD_MONTHS('01-JUN-10',n-1) <= NVL(add_months('01-JUN-10', :monthcount-1),:p_month)
    ORDER BY n ASC
    ) , dates as (
    select     trunc(trunc(m.current_month, 'MM'), 'D') + n - 1 calendar_date,
         trunc((n - 1) / 7) AS week_num,
                    m.current_month as current_month
    from     numbers, months m
    where trunc(dom.schedule.calendar_begin(m.current_month) + n - 1, 'd') <= last_day(m.current_month)
    Order By week_num, calendar_date
    select dates.week_num, edate, name from (
    --week 0
    select '30-MAY-10' as edate, 'JJ' as name from dual union
    select  '31-MAY-10' as edate, 'MK' as name from dual union
    select  '01-JUN-10' as edate, 'MK' as name from dual union
    select  '01-JUN-10' as edate, 'BK' as name from dual union
    select  '01-JUN-10' as edate, 'JJ' as name from dual union
    select  '04-JUN-10' as edate, 'KK' as name from dual union
    select  '04-JUN-10' as edate, 'LA' as name from dual      union
    -- week 1
    select  '06-JUN-10' as edate, 'BK' as name from dual union
    select  '06-JUN-10' as edate, 'JJ' as name from dual union
    select  '07-JUN-10' as edate, 'KK' as name from dual union
    select  '11-JUN-10' as edate, 'LA' as name from dual      
    ) a  join dates on dates.calendar_date = a.edate   
    order by week_num, to_date(edate);CURRENT RESULT :
    WEEK_NUM             EDATE                NAME
    0                   30-MAY-10            JJ
    0                   31-MAY-10             MK
    0                   01-JUN-10             MK
    0                   01-JUN-10             JJ
    0                   01-JUN-10             BK
    0                   04-JUN-10             KK
    0                   04-JUN-10             LA
    1                   06-JUN-10             BK
    1                   06-JUN-10             JJ
    1                   07-JUN-10             KK
    1                   11-JUN-10             LAREQUIRED RESULT:
    WEEK_NUM             EDATE                NAME
    0                   30-MAY-10             JJ
    0                   30-MAY-10            null
    0                   30-MAY-10            null
    0                   31-MAY-10            MK
    0                   31-MAY-10            null
    0                   31-MAY-10            null
    0                   01-JUN-10             BK
    0                   01-JUN-10              JJ
    0                   01-JUN-10             MK
    0                   02-JUN-10             null
    0                   02-JUN-10             null
    0                   02-JUN-10             null
    0                   03-JUN-10             null
    0                   03-JUN-10             null
    0                   03-JUN-10             null
    0                   04-JUN-10             KK
    0                   04-JUN-10             LA
    0                   04-JUN-10             null
    0                   05-JUN-10             null
    0                   05-JUN-10             null
    0                   05-JUN-10             null
    --Number of Week 1 records should be 14 = (max occurances on 06-JUN-10)  * 7
    1                   06-JUN-10             BK
    1                   06-JUN-10             JJ
    1                   07-JUN-10             KK
    1                   07-JUN-10             null
    1                   08-JUN-10             null
    1                   08-JUN-10             null
    1                   09-JUN-10             null
    1                   09-JUN-10             null
    1                   10-JUN-10             null
    1                   10-JUN-10             null
    1                   11-JUN-10             LA
    1                   11-JUN-10             null
    1                   12-JUN-10             null
    1                   12-JUN-10             nullI would appreciate it if you could help me to find efficient way to achieve this?
    Thanks,
    GM
    Edited by: user12068331 on Sep 28, 2010 2:17 PM
    Edited by: user12068331 on Sep 28, 2010 2:48 PM

    Ok,
    Few things to clarify first :
    1 - How do you define week number ?
    Oracle has 2 different way for week number : normal week number (WW) and isoweek (IW).
    is your weeknumber one of those, or is it something else ?
    2 - Depending on the country the week doesn't start on the same day : in France (as most of Europe I think) first day is monday, where in the USA (as far as I know) first day is sunday.
    the to_char builtin function can display weeknumber :with a as (
    --week 0
    select 0 as weeknum, to_date('30-MAY-2010','DD-MON-YYYY') as edate, 'JJ' as name from dual union all
    select 0 as weeknum, to_date('31-MAY-2010','DD-MON-YYYY') as edate, 'MK' as name from dual union all
    select 0 as weeknum, to_date('01-JUN-2010','DD-MON-YYYY') as edate, 'MK' as name from dual union all
    select 0 as weeknum, to_date('01-JUN-2010','DD-MON-YYYY') as edate, 'BK' as name from dual union all
    select 0 as weeknum, to_date('01-JUN-2010','DD-MON-YYYY') as edate, 'JJ' as name from dual union all
    select 0 as weeknum, to_date('04-JUN-2010','DD-MON-YYYY') as edate, 'KK' as name from dual union all
    select 0 as weeknum, to_date('04-JUN-2010','DD-MON-YYYY') as edate, 'LA' as name from dual union all
    -- week 1
    select 1 as weeknum, to_date('06-JUN-2010','DD-MON-YYYY') as edate, 'BK' as name from dual union all
    select 1 as weeknum, to_date('06-JUN-2010','DD-MON-YYYY') as edate, 'JJ' as name from dual union all
    select 1 as weeknum, to_date('07-JUN-2010','DD-MON-YYYY') as edate, 'KK' as name from dual union all
    select 1 as weeknum, to_date('11-JUN-2010','DD-MON-YYYY') as edate, 'LA' as name from dual
    select to_char(a.edate,'IW') isoweek, to_char(a.edate,'WW') numweek, a.*
    from a;
    IS NU    WEEKNUM EDATE                          NA
    21 22          0 Sunday    30/05/2010 00:00:00  JJ
    22 22          0 Monday    31/05/2010 00:00:00  MK
    22 22          0 Tuesday   01/06/2010 00:00:00  MK
    22 22          0 Tuesday   01/06/2010 00:00:00  BK
    22 22          0 Tuesday   01/06/2010 00:00:00  JJ
    22 23          0 Friday    04/06/2010 00:00:00  KK
    22 23          0 Friday    04/06/2010 00:00:00  LA
    22 23          1 Sunday    06/06/2010 00:00:00  BK
    22 23          1 Sunday    06/06/2010 00:00:00  JJ
    23 23          1 Monday    07/06/2010 00:00:00  KK
    23 24          1 Friday    11/06/2010 00:00:00  LA
    11 rows selected.

  • How to select records based on Max/Min on different columns and group by

    I have a table with 5 columns(a,b,c,d,e), i need to select records based on MAX(c),Max(D) and Min(e) group by a,b. i am trying using : select max(c),max(d),min(e) from table group by a,b. this is not working. its giving me 1 6 1
    a b c d e
    1 1 1 2 1
    1 1 1 6 4
    1 1 1 6 3
    when i group by a,b i am expecting the record 1 6 3
    Please help me with this.. Thanks in advance....

    Hi,
    Welcome to the forum!
    962163 wrote:
    I have a table with 5 columns(a,b,c,d,e), i need to select records based on MAX(c),Max(D) and Min(e) group by a,b. i am trying using : select max(c),max(d),min(e) from table group by a,b. this is not working. its giving me 1 6 1
    a b c d e
    1 1 1 2 1
    1 1 1 6 4
    1 1 1 6 3
    when i group by a,b i am expecting the record 1 6 3It looks to me like "1 6 1" is the correct answer. You're asking for the lowest value of e, and 1 is lower than 3.
    Maybe you don't want MIN (e). Explain why you want 3 (that is, how you decided that 3 is the correct value for the last column) and someone will help you code it.
    Edited by: Frank Kulash on Sep 28, 2012 6:17 PM
    Whenever you have a problem, you should psot CREATE TABLE and INSERT statements for your sample data. That way, the people who want to help you can re-create the problem and test their ideas. It often helps to clarify the problem, too. since this is your first message, I'll do it for you:
    CREATE TABLE     table_x
    (       a     NUMBER
    ,     b     NUMBER
    ,     c     NUMBER
    ,     d     NUMBER
    ,     e     NUMBER
    INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 2, 1);
    INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 6, 4);
    INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 6, 3);
    COMMIT;

  • Wants delete user based on their last login details...

    Hi All,
    I have one question regarding oracle database user management. I have approx 300 users in my each Database and I know many of them are not actively used. I want to generate users report based on their last login information. I want to fetch list of users who is not logged in database since last 4 months and are eligible for delete operation.  Please guide me how to find this details.
    Thanks in advance...

    user12115, but really even if the logon time was not present and you only had the logoff time you know when the customer last used the system and relistically you could work with that.  Rather than audit user session connection due to the large number of connections/disconnects we have per day we created a database logon event trigger that updates an IOT for the username, logon_date of the OS user connecting.  If no row is updated we insert the username.
    Also keep in mind that many web based applications connect to the Oracle rdbms using an application username as not as the real end user.  In such a case auditing will not catch the real end user nor will the logon trigger unless the application uses dbms_application_info to post the real end username to Oracle.  If this is not true in your shop today it might be tomorrow so keep this potential issue in mind.
    HTH -- Mark D Powell -- 

  • Identifying records based on one or more common fields

    Hi all
    This should be easy - but going round in circles. I want to be able to group together records based on whether at least one field is the same as the corresponding field in a different record.
    So:
    Account No Tel No PostCode
    ABC123 17654231 TS24 4ZX
    DEF987 8764573 NE1 1AL
    QWE921 17654321 SR9 8BD
    ASD579 24697615 SR9 8BD
    So in the above example the first, third and fourth record would all form one group because the first links to the third based on Tel No and the third links to the fourth based on PostCode. The second record will be in a group of its own. I want to output the above (into a new table) with an additional field linking relevant records together (a group number).
    My first pass was to simply:
    select the minimum group number from the output table where either the Tel No or Phone No match the current record. If no match then create a new record for this record with the next incremental group number.
    This would give
    Account No Tel No PostCode Group
    ABC123 17654231 TS24 4ZX 1
    DEF987 8764573 NE1 1AL 2
    QWE921 17654321 SR9 8BD 1
    ASD579 24697615 SR9 8BD 1
    On the surface that looks OK. The problem occurs if for instance the PostCode in the second record is 'SR9 8BD'. The output would be identical to the above - but I want them to all share the same group number as now there is some commonality between all four records. I'm sure I need to do something recursively but just can't get my head around it.
    Would really appreciate some help.
    Thanks
    Ian

    Hi, Ian,
    Welcome to the forum!
    Be sure to read the forum FAQ {message:id=9360002} It contains several tips that can help you get good answers quickly
    976560 wrote:
    Hi all
    This should be easy - but going round in circles.Ironically, the solution below involves NOCYCLE.
    I want to be able to group together records based on whether at least one field is the same as the corresponding field in a different record.
    So:
    Account No Tel No PostCode
    ABC123 17654231 TS24 4ZX
    DEF987 8764573 NE1 1AL
    QWE921 17654321 SR9 8BD
    ASD579 24697615 SR9 8BDWhenever you have a problem, please post CREATE TABLE and INSERT statments for all tables inolved. Since this is your fist message, I'll do it for you:
    DROP TABLE     table_x;
    CREATE TABLE  table_x
    (   Account_No     VARCHAR2 (10)     PRIMARY KEY
    ,   Tel_No      VARCHAR2 (10)
    ,   Post_Code     VARCHAR2 (10)
    INSERT INTO table_x (account_no, tel_no,     post_code)
           VALUES         ('ABC123',       '17654321', 'TS24 4ZX');
    INSERT INTO table_x (account_no, tel_no,     post_code)
           VALUES         ('DEF987',       '8764573',  'NE1 1AL');
    INSERT INTO table_x (account_no, tel_no,     post_code)
           VALUES         ('QWE921',       '17654321', 'SR9 8BD');
    INSERT INTO table_x (account_no, tel_no,     post_code)
           VALUES         ('ASD579',       '24697615', 'SR9 8BD');
    COMMIT;
    So in the above example the first, third and fourth record would all form one group because the first links to the third based on Tel No Be careful! It looks like you made a typo there. I changed the number ending in '231' to '321'.
    and the third links to the fourth based on PostCode. The second record will be in a group of its own. I want to output the above (into a new table) with an additional field linking relevant records together (a group number).
    My first pass was to simply:
    select the minimum group number from the output table where either the Tel No or Phone No match the current record. If no match then create a new record for this record with the next incremental group number.
    This would give
    Account No Tel No PostCode Group
    ABC123 17654231 TS24 4ZX 1
    DEF987 8764573 NE1 1AL 2
    QWE921 17654321 SR9 8BD 1
    ASD579 24697615 SR9 8BD 1
    On the surface that looks OK. The problem occurs if for instance the PostCode in the second record is 'SR9 8BD'. The output would be identical to the above - but I want them to all share the same group number as now there is some commonality between all four records. I'm sure I need to do something recursively but just can't get my head around it.You said it exactly: you need to do something recursively.
    What features of Oracle SQL are recursive? CONNECT BY (as shown below) and, starting in Oracle 11.2, recursive WITH clauses.
    Would really appreciate some help.Here's one way to do that:
    CREATE TABLE     table_y
    AS
    WITH   got_related_account_no      AS
         SELECT  table_x.*
         ,     CONNECT_BY_ROOT account_no     AS related_account_no
         FROM     table_x
         CONNECT BY NOCYCLE  account_no     != PRIOR account_no
              AND   (         tel_no      = PRIOR tel_no
                    OR    post_code      = PRIOR post_code
                 -- OR ...   -- other columns as needed
    SELECT       account_no, tel_no, post_code
    ,       DENSE_RANK () OVER (ORDER BY  MIN (related_account_no))
                         AS grp
    FROM       got_related_account_no
    GROUP BY  account_no, tel_no, post_code
    ;This will work in Oracle 10.1 and up.
    At the end of this, table_y contains:
    ACCOUNT_NO TEL_NO     POST_CODE         GRP
    ABC123     17654321   TS24 4ZX            1
    ASD579     24697615   SR9 8BD             1
    DEF987     8764573    NE1 1AL             2
    QWE921     17654321   SR9 8BD             1

  • Is it possible to get the updated table records based on date & time.

    Is it possible to get the updated table records based on date & time in oracle.
    Thanks in advance.

    no, actually i am asking update records using 'UPDATE
    or DELETE' statement, but not insert statement.
    Is it possible?
    I think we can do using trigger on table, but problem
    is if i am having 20 tables means i have to write 20
    trigger. i don't want like this.Of course it's still possible, typically you'll find applications with a column LAST_UPDATE, probably a LAST_UPDATED_BY and so on column. You don't say what your business need is, if you just want a one of query of updates to particular records and have a recent version of Oracle, then flashback query may well help, if you want to record update timestamps you either have to modify the table, or write some code to store your updates in an audit table somewhere.
    Niall Litchfield
    http://www.orawin.info/

  • How  to   find  article based  support  for  ipad  or  technical notes

    how  to   find  article based  support  for  ipad  or  technical notes

    The problem comes from VBUK/VBUP which are the control tables for most of SD tables (from VBAK/P to LIKP/PS and VBRK/P) and manage uniqueness of id in the module (and stores statuses). Even item tables don't refer to their header but both refer to the same VBUK record.
    e.g.
    LIPS : VBELN/POSNR -> VBUK/VBUP -> but you will only find LIKP/PS itself and no record in VBAK/VBAP
    LIPS : VBELV/POSNV -> VBUK/VBUP -> you should find VBAK/VBAP
    The table VBFA "Sales Document Flow" manages the relations from/to between two different SD documents which exist in VBUL/P and in only one other table depending on type of document. (Also note that the exact relationship may sometimes be modified to some extent by Customizing SD.)
    As Katan wrote, look for views defined in ddic, look also at logical databases (SE36) like VLV.
    You can also find valuable information in OSS notes/documents like 185530 - Performance: Customer developments in SD.
    Regards,
    Raymond

  • Error While Assigning Ad insert contract from Ad insert orders.

    Hi Experts,
    While performing the transaction for u2018Assigning Ad inserts Contracts from Ad Insert ordersu2019, Iu2019m getting the following error.
    Message no. JVSD056
    I did the following steps.
    a) Created a geographical unit.
    b) Assigned that geographical unit in the BP master of the retailer with a newly created assignment type.
    c) Linked the geographical unit in the booking unit for Ad inserts  in MAM .
    d) Created an Ad insert order in MAM by using the booking unit which has the geographical unit assignment.
    Then tried to execute the u2018Assign Ad inserts Contracts from Ad insert orders. The error message is JVSD056.
    Appreciate if anyone can help me in this. This is the first time we are doing this.
    Regards,
    Suresh

    Hi Helios,
    I hav egone through the document.However i have resolved the error ar: illegal option -- F by following the doc id Doc ID 785828.1
    Now i am facing error while relinking
    Relinking module 'FNDCORE.dll' in product fnd ...
    Removing any existing temp directory
    rm -rf temp
    creating the temp directory
    mkdir temp
    changing permissions for the temp directory
    chmod 777 temp
    Getting the object file names for this FNDCORE.dll
    gnumake -f E:/oracle/apps/apps_st/appl/admin/PROD/out/link_fnd_5136.mk fndcore.LIST
    E:/oracle/apps/apps_st/appl/admin/PROD/out/link_fnd_5136.mk:760: *** target pattern contains no `%'. Stop.
    Unable to get the objects for module "FNDCORE.dll".
    See error messages above (also recorded in log file)
    for possible reasons for the failure.
    adrelink is exiting with status 1
    Please advice
    Regards,
    SRK

  • Purchase orders and their open order quantity with their due dates.

    hi friends
    i need to build  a query  where i can see the purchase orders and their open order quantity and their respective due delivery dates.i have never done  this.
    ME2M serves my requirement  upto little but i cannot see the delivery dates in that report.
    please help mein finding the steps involved in building the query.
    Thanks
    Alahari

    Use the table EKPO and EKKO
    adhoc querry is a tool in which we can create report
    to get report we have to use three t. codes
    1.sq03-->is for to create user group
    2.sq02--.is for infoset Querry
    3.Sq01-->for exact querry
    try with these codes or revert with ur response
    follow the link for query creation
    First check this link,
    SAP Query Creation
    SAP Query -A Reporting Tool for Functional Consultants(Part 2)
    SAP Query 1
    SAP Query -A Reporting Tool for Functional Consultants (Part 1)
    Always after going to SQ02 or SQ01 T Code ,first click on Environment in the menu ->Query Areas-->
    Standard Area Client specific and then start creating the Infoset or else the query.
    Still if you are not satisfied means,please revert back.

  • Purchase orders and their open order quantity with their due delivery date

    hi friends
    i need to build a query where i can see the purchase orders and their open order quantity and their respective due delivery dates.i have never done this.
    ME2M serves my requirement upto little but i cannot see the delivery dates in that report.
    please help mein finding the steps involved in building the query.
    Thanks
    Alahari

    Deliver date is available in table EKET field EINDT.
    Use table : EKKO ,EKPO, EKET.

Maybe you are looking for