How to select the next record

Hi All,
i have a table like below. i need the next record after the status_code = 5.
pls help
JOB
job_id               prnt_job_id             status_code
2282                 2281                        4
2283                 2281                        4
2284                 2281                        5
2287                 2281                        2
2289                 2281                        2next record after status_code = 5 is
2287                 2281                        2

SELECT next_job_id,
  next_prnt_job_id,
  next_status_code
FROM
  ( WITH t1 AS
  ( SELECT 2282 job_id, 2281 prnt_job_id, 4 status_code FROM dual
  UNION ALL
  SELECT 2283, 2281, 4 FROM dual
  UNION ALL
  SELECT 2284, 2281, 5 FROM dual
  UNION ALL
  SELECT 2287, 2281, 2 FROM dual
  UNION ALL
  SELECT 2289, 2281, 2 FROM dual
SELECT lead(job_id,1) over(order by rownum) next_job_id,
  job_id,
  lead(prnt_job_id,1) over(order by rownum) next_prnt_job_id,
  prnt_job_id,
  lead(status_code,1) over(order by rownum) next_status_code,
  status_code
FROM t1
WHERE status_code=5

Similar Messages

  • How to select the first record?

    Hi,
    Could anyone tell me how to select the first record of every
    group?
    ex, I want to find out every customer their first purcaseDate.
    CustomerID PurcaseDate Region
    A00000001 2001/01/01 AA
    A00000001 2001/02/02 AA
    A00000002 2001/03/01 AC
    A00000002 2001/05/07 AC
    A00000003 2001/03/05 DD
    result:
    A00000001 2001/01/01 AA
    A00000002 2001/03/01 AC
    A00000003 2001/03/05 DD
    Thanks

    Vincent,
    You could do it as Carl suggested, with a couple of
    corrections.  You would need to include the CustomNo column in
    the order by clause of your cursor.  You would also need to add
    a where clause to your update statement, otherwise everywhere
    Region in the table would be updated with the same value of the
    last CustomNo in the cursor, regardless of the CustomNo in the
    table.  See corrected code below:
    DECLARE
      CURSOR     cust
      IS
      SELECT     DISTINCT CustomNo, Region, Purchase_Date
      FROM       my_table
      ORDER BY   CustomNo, Purchase_Date, Region;
      c_customer VARCHAR2 (9) := '...';
      c_region   VARCHAR2 (2) := '..';
      cntr       NUMBER := 0;
    BEGIN
      FOR x IN cust
      LOOP
        IF x.CustomNo != c_customer
        THEN
          c_customer := x.CustomNo;
          c_region := x.Region;
        ELSE
          UPDATE my_table
          SET    Region = c_region
          WHERE  CustomNo = c_customer;
          cntr := cntr + 1;
          IF cntr = 25
          THEN
            COMMIT;
            cntr := 0;
          END IF;
        END IF;
      END LOOP;
      COMMIT;
    EXCEPTION
      WHEN OTHERS THEN 
        NULL;
    END;
    Another option is that you could just use one update statement,
    like this:
    UPDATE my_table a
    SET    Region =
           (SELECT DISTINCT Region
            FROM   my_table b
            WHERE  (CustomNo, Purchase_Date) IN
                   (SELECT   CustomNo, MIN (Purchase_Date)
                    FROM     my_table
                    GROUP BY CustomNo)
            AND    a.CustomNo = b.CustomNo)
    Barbara

  • How to find the next record b4 the loop end

    hai all
    i have suffering big problem... i have the  internal table  call IT_ITAB.. so i can go to the rerecord by record using loop comand..
    example:
    loop at IT_ITAB.
    1.record1
    2.record2
    3.record3
    4.record4
    endloop.
    Allways end of loop go to next record...... my problem is before end of the loop i want to check the next record... how should i do it... please help me...
    regard
    nawa

    Hi,
    One approach u can follow is that copy the data of the internal table into another one.
    Maintain an integer type variable which will contain the index value of the loop. Check the entry from other table.
    e.g.
    Loop at itab1.
    ctr = sy-tabix + 1.
    read itab2 index ctr.
    This way u can check the next record while u r still in loop.
    Hope it helps.
    Regards,
    Himanshu

  • How to Select the duplicate records in the table

    Hi
    SELECT * FROM gin A WHERE A.sale_order_id IN (
    SELECT sale_order_id FROM gin GROUP BY sale_order_id
    HAVING COUNT(sale_order_id)>1)
    AND A.ROWID!=MIN (ROWID))
    ERROR at line 4:
    ORA-00934: group function is not allowed here
    Thanks
    Vikas Singhal

    Try this out
    select *
    from gin a
    where a.rowid > any (select b.rowid
    from gin b
    where a.col1 = b.col1
    and a.col2 = b.col2);
    Regards
    Ozy
    [www.oraclevillage.com]
    Edited by: Ozy on Feb 4, 2009 4:12 AM

  • How to restrict the last record and not moving to next reocrd

    1) how to restrict the last record and not moving to next reocrd.
    2) Also for the F6 key(for new record).

    When you are on the last record, next-record will create a new one, so that my question is do you want to forbid new record creation.
    Francois

  • How can i select the next column instead of next row when press enter key

    I need to know how can i select the next column instead of next row when i press the enter key.By default ,when i press enter key the next row is selected and the column remain unchanged but I wants opposite that is the row should remain unchanged but column index will changed.
    Thanks to all.

    Well, the right arrow key will already move you to the next column, so the easiest way to do this is to modify the InputMap to have the Enter key invoke the same Action as the right arrow key.
    You can search the forum for my "Table Actions" (without the space) example that will show you how to do this.

  • How can I select the next item in table view?

    Hey,
    I'd like to select the next item ,but I have no idea about this ?do you have any suggestion?
    eg:
    the second item is being selected now,I need to select the third one in my code ,how can I implement this function?

    private IntegerProperty index = new SimpleIntegerProperty();
        public final double getIndex() {
            return index.get();
        public final void setIndex(Integer value) {
            index.set(value);
        public IntegerProperty indexProperty() {
            return index;
        }Get the selected item:
    table.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
                @Override
                public void changed(ObservableValue observable, Object oldvalue, Object newValue) {
                    Person selectedPerson = (Person) newValue;
                    setIndex(data.indexOf(newValue));
            });Select the next index:
    table.getSelectionModel().select(index.get() +1  );

  • How can I select the random records in u201Cstep loopu201D.

    Hi, Experts,
    I am using step loop to display the data on screen now I want to select the random records from this step loop display. Like 1st 3rd or 5th record, is there any way to select the records,
    like I did in Table control there was a filed in internal table named marked char length 1, I gave this field name in u201Cw/ SelColumnu201D it fill that field with u2018Xu2019 from where I can get the info about the selected records, in this way I can easily perform the operation on that internal table with the help of that marked field.
    Is there any way to select the records in step loop too ?
    Kind Regards,
    Faisal

    thanks for replay shwetali,
    but i just gave you example of random records with 1st 3rd and 5th my goal is not select only these records. i want to select the random mean any records from the step loop display.
    like we can select from the table control. and when select any record it place 'X' in the given internal table field.
    Thanks and kind Regards,
    Faisal

  • Refresh page with data from the Next Record in the Table through a Button

    Scenario: Record of a table “prototype” is made up of 8 columns,
    key_col,
    text_col,
    label1_col, label2_col, label3_col,
    check1_col, check2_col, check3_col,
    I have created the following items on a page:
    a) A Display Only item that is populated through a SQL query
    “SELECT text_col from prototype where rownum=key_seq.NEXTVAL “.
    b) Hidden item for the database columns “label1_col, label2_col, label3_col”
    Source type for the hidden items is of type SQL query, Source expression is:
    Select label1_col from prototype where rownum=key_seq.NEXTVAL ;
    Select label2_col from prototype where rownum=key_seq.NEXTVAL ;
    Select label3_col from prototype where rownum=key_seq.NEXTVAL ;
    (key_seq is a sequence).
    c) Checkbox item for the database columns “ check1_col, check2_col,check3_col"
    d) The labels for the above checkbox items are &label1_col. , &label2_col. , &label3_col.
    I have created a Save button to save the state of the checkboxes; (STATIC:;1 )
    I want the page to be refreshed with the data from the next record (Fields text_col, label1_col, label2_col, label3_col) through a “ Next” Button.
    Can I please know how I can achieve this?
    Thanks in advance

    If you need the value that is entered in the textbox as the email body, then try this..
    <html>
    <HEAD>
    <title>WebForm1</title>
    <script language="javascript">
    function mailHTML() {
    var content=document.getElementById('textBox').value;
    location.href="mailto:?body="+encodeURI(content);
    </script>
    </head>
    <body>
    <form name="theform" id="theform">
    <div name="body1"/>
    <input type="text" value="Test" id="textBox"/>
    <input type="button" value="Send Email" onClick="mailHTML()"/>
    </div>
    </form>
    </body>
    </html>

  • How to select the Alt BOM in the Sub-Contract PO

    Dear All,
    please tell me how to select the alternative BOM in the sub -contracting purchase order.
    for the above said requirement i have cretaed production versions and the BOMselction method also i have selcted in the material master data as "2" means BOM by produ ction version.
    so how can i select the alt BOm in theSub-contracting PO.
    Thanx in advanvce
    regards
    Srinivas

    Hi,
    SAP help says you have to write the production version in the subcontracting info record:
    http://help.sap.com/saphelp_46c/helpdata/en/b2/fa1ed4d51d11d1a69e0000e83235d4/frameset.htm
    http://help.sap.com/saphelp_46c/helpdata/en/35/b0e96787a62488e10000009b38f9b7/frameset.htm
    (I've checked a subcon-info record but sorrowfully I havent found a field for this...if you can find please let me know)
    BR
    Csaba

  • How to handle the control records in case of file to idoc scenario.

    Hi All,
    can you please clarify me how to handle the control records in case of file to idoc scenario.

    Hi,
    In File to Idoc scenario even though you selected apply control record values from payload and you are not getting those correct values which you have provided in the mapping.
    Also check the checkboxes Take sender from payload and Take receiver from payload along with the Apply control record values from payload checkbox
    Regards
    Seshagiri

  • How to select the inklist items in the active document?

    From the below code, i can get the inklist information. But i could not know how to select the spot(InkType.CUSTOMINK) color items in the illustrator activedocument.
    var docRef=app.activeDocument;
    var S1 = 0;
    for(i=docRef.inkList.length-1;i>=0;i--)
    var inkRef=docRef.inkList[i];
    var inkRefName=inkRef.name;
    if(inkRef.inkInfo.kind=="InkType.CUSTOMINK")
    alert(inkRefName);
    //Select the items?
    Could You please advice me.

    Hi Giri
    >> First define the Posting Period for 2010 and create the numbering series for documents for 2010.
    Done.
    >> set as default of numbering series for 2010.
    Done.
    so this series will come defaultyly,if u want to post some document in 2009 then select the numbering series in documents manually,
    >> How?
    I am trying with a FMS to update the invoice and it's ok, but the journal entry takes 2010 number series.
    I have:
    - one serie DEC09.
    - other JAN10.
    I want to record invoices with date in Dec 2009 now and the journal entries with DEC09 serie, and invoices with date in Jan 2010 and the journal entries with JAN10 at the same time.
    Is this possible?
    Kind regards.
    Agustin Marcos Cividanes

  • How  to  copy  the  table1selected  records into table 2 in webdynpro java.

    Hi 
           how  to  copy  the  table1selected  records into table 2 in webdynpro java.
    venkat
    Edited by: venkatpvr on Sep 23, 2011 11:53 AM

    Hi Venkat,
    You have 2 Value Nodes one for Table1 and second for Table2.
    Table1 node having one more Value Attribute i.e check Box data type is Boolean. Now you are requirement are select records from Table1 Node and click on One Method that records will moves to Second Table2 Node.
    Create One Method for getting the Records from 1-Table to 2-Table
    CopytoTable2 ()
    In this method you have to write code like this
    If (wdContext.nodeTable1.Checkbox(true))
    If(1. Check the Table1 Value Node Size()>0)
    Get the Table1 records and set to table2 Value node.
    Else
    Please select check box// Error message
    Hope this helps!!
    Regards
    Vijay K

  • How to see the data records for a dso based upon the request id?

    Hi all,
    How to see the data records based upon the request id on the dso.
    I need to see the data for a dso based upon the request id 444493 loaded from another dso through repair full update.
    thanks

    Hi,
    Step 1: select your request from DSO request tb
    Step 2: Select your DSO just above your contents/requests/reconstruction tabs
    Step 3: Click contents(Spectacles symbol) in the top area of your screen
    Step 4: Slect the required fields
    Regards,
    Suman

  • How to handle the bad record while using bulk collect with limit.

    Hi
    How to handle the Bad record as part of the insertion/updation to avoid the transaction.
    Example:
    I am inserting into table with LIMIT of 1000 records and i've got error at 588th record.
    i want to commit the transaction with 588 inserted record in table and log the error into
    error logging table then i've to continue with transaction with 560th record.
    Can anyone suggest me in this case.
    Regards,
    yuva

    >
    How to handle the Bad record as part of the insertion/updation to avoid the transaction.
    >
    Use the SAVE EXCEPTIONS clause of the FORALL if you are doing bulk inserts.
    See SAVE EXCEPTIONS in the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/tuning.htm
    And then see Example 12-9 Bulk Operation that continues despite exceptions
    >
    Example 12-9 Bulk Operation that Continues Despite Exceptions
    -- Temporary table for this example:
    CREATE TABLE emp_temp AS SELECT * FROM employees;
    DECLARE
    TYPE empid_tab IS TABLE OF employees.employee_id%TYPE;
    emp_sr empid_tab;
    -- Exception handler for ORA-24381:
    errors NUMBER;
    dml_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT(dml_errors, -24381);
    BEGIN
    SELECT employee_id
    BULK COLLECT INTO emp_sr FROM emp_temp
    WHERE hire_date < '30-DEC-94';
    -- Add '_SR' to job_id of most senior employees:
    FORALL i IN emp_sr.FIRST..emp_sr.LAST SAVE EXCEPTIONS
    UPDATE emp_temp SET job_id = job_id || '_SR'
    WHERE emp_sr(i) = emp_temp.employee_id;
    -- If errors occurred during FORALL SAVE EXCEPTIONS,
    -- a single exception is raised when the statement completes.
    EXCEPTION
    -- Figure out what failed and why
    WHEN dml_errors THEN
    errors := SQL%BULK_EXCEPTIONS.COUNT;
    DBMS_OUTPUT.PUT_LINE
    ('Number of statements that failed: ' || errors);
    FOR i IN 1..errors LOOP
    DBMS_OUTPUT.PUT_LINE('Error #' || i || ' occurred during '||
    'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX);
    DBMS_OUTPUT.PUT_LINE('Error message is ' ||
    SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
    END LOOP;
    END;
    DROP TABLE emp_temp;

Maybe you are looking for

  • Looking for a good group texting app. Any suggestions?

    hey, i'm looking for an app that lets me create a group and then have a group conversation with everyone in that group where we can all see the comments of other people. For example, if i need to talk to the family in a group conversation I want to c

  • Photo Books - Crop and Color Issues from Kodak Gallery

    I've been spending a good amount of time creating photo books and ordering them from Kodak using the built-in online ordering feature. I've noticed several items that I was curious if others have any experience perspective on. 1. Cropping. For a flex

  • 30 Gig color ipod is completely frozen

    I've had this ipod since June. Yesterday I would try to play a song and it would just start skipping to the next song in the play list. Nothing would play. I would select a song and it would just move from one song to the next in the playlist until i

  • Analog Trigger unavialable in PXIe-4353

    Hello, I'd be grateful for some help with my case. I'm building a VI for acquisition of multiple signals from thermocouples. My hardware is NI PXIe-1073 chassis with PXIe-4353 module to read the signals. The problem is that I want to use an Analog Ed

  • Strange thing in division - star symbol instead of number

    Hi, here is a piece of code: data zkbetr like KONV-KBETR. zkbetr = konv-kbetr / 10. "value of konv-kbetr is 210.00 at this step, I see it in debugger result value of zkbetr is * instead of 21 any ideas why I have this star symbol? Regards, Mindaugas