Pulling out two records at a time

I have a TABLE with multiple records in it, of which i want to pull out two records at a time (as if they were one record), of those records that meet the WHERE criteria. Order is not important. Basically, i have a TABLE of things that wither need processing or have been processed already. I can process two at a time. (In a related search, that i am not up to yet, i can do 20 at a time.) How would i go about doing that?
My first thought was a CTE with ROW_NUMBER() RN, using CONNECT BY RN = PRIOR RN + 2, and have a sub-query (or joined TABLE) pull out the second record:
WITH Moo (SELECT ... ROW_NUMBER RN FROM Table WHERE ...)
SELECT ..., (SELECT ... FROM FROM Moo Moo2 WHERE Moo2.Id = Moo.Id + 1)
FROM Moo CONNECT BY Id = PRIOR Id + 2;
Or a join. Is there a better way to approach it?

Pretty much everything you just said is wrong.
>
I generally keep away from CURSORs, as i want the DB to handle the set processing for me, as opposed to a CURSOR which tells the DB how to do it's job.
>
If you do any DB queries then you are using cursors. You have the wrong idea about them. All result sets are obtained using a cursor. A cursor does NOT tell a DB how to do a job; that is what the query and execution plan do.
>
(And, Tom Kyt's mantra of "You should do it in a single SQL statement if at all possible") But that's just a rule of thumb.
>
No - that isn't a rule of thumb. That is exactly what you should do if possible which is what I said. But I also said
>
Well the general use is to use SQL instead of PL/SQL but since you already need to use a function you might as well make that function as efficient as possible.
>
If you are already using a function then you should get the most bang for the buck from it and make it as efficient as possible.
>
If the CURSOR is the most efficient, so be it. But as you point out, if i'm already going to use a CURSOR, i might as well do all the work in the CURSOR LOOP. Why bother switching contexts.
>
All queries are done using cursors. It isn't a question of whether they are more efficient; it is the only way possible. I think you are referring to a user creating an explicit cursor and performing explicit manipulation of that cursor. That isn't normally what you want to do.
A cursor loop is the slowest way to process results especially if all you are doing is row-by-row processing to perform essentially SQL-related work. PL/SQL should be used for the transactional part of the processing. In your case that transactional use is consolidating two records together for specialized processing.
As for context switches if you perform any PL/SQL you are going to have a context switch: functions, procedures, triggers. The function you already planned to use would have caused a context switch. What I am saying is that if you are going to perform a context switch then you want to maximize the amount of work (transactional work) done in the PL/SQL engine so that you minimize the context switching.
You still haven't explained exactly why 2 records at a time is any more ideal than 1 or if you could also process 50, 100, or 10000 at a time. Is the limit what needs to be passed somewhere else? What is the reason for a max of two? What exactly are you doing with the data to prepare it before you have to pass it on?
Bulk collect processing is more efficient, with fewer context switches, if you process 20, 50, or 100 records in the loop at a time.
See Chap 13 Using Pipelined and parallel Table Functions in the Data Cartridge Dev Guide
http://docs.oracle.com/cd/B28359_01/appdev.111/b28425/pipe_paral_tbl.htm

Similar Messages

  • Read-only report for two records

    I have a table that has two records per one parent record.
    I want to display these two records on a page containing read-only fields (items) of the parent record.
    I was thinking of just having two regions each of which would perform a SELECT to pull it's respective record.
    Would I have to create fields for each record to load the fields into and then make each field be read-only?
    I did this to load one of the records into a form:
    select field1, field2 into px_field1, px_field2 where...
    I just wondered if there was an easier way other than creating two sets of fields to hold each record.
    I tried some of the canned reports using the wizard. Easy enough to pull the two records but the formatting goes a mile to the right and this page is to be used for printing.
    Thanks,

    semaphore,
    Have you considered using a Master Detail form. The forms have record navigation and the detail columns of the form can be altered to Display As Standard Report Column making them read only. As well, the Master part of the form can also be configured to be read or display only.
    Jeff

  • Reducing time while Filtering Out New Records with the Same Key

    Hi Experts,
    I have an issue .. I am trying to load data into 0MATERIAL . While loading via DTP the step u201CFilter Out New Records with the Same Keyu201D   takes much time for processing . For each datapackage it is taking around 30 minutes to filter out new records with the same key .  While for other master data it hardly takes 5 minutes.
    Any pointers how to reduce the timeu2026
    Thanks in advance
    Sam

    Hello,
    No there is no need to do that change then.
    Can you tell me are you doing a full load daily to 0MATERIAL object.
    why dont you use delta.
    Also if the DTP is of type FULL, then are you deleting the previous PSA requests.
    Maybe you can ask the basis guys to check with a trace what is really happening on the DB side during this 30 mins and then maybe we can find the needed fix.
    Regards,
    Shashank

  • Pull out tab - two way to scroll

    Hello!
    I wanted to reproduce the 'two way scroll pull out tab' I saw on the DPS tips app (Advanced Overlays).
    I was able to make the the pull out tab and to include another scrolling frame inside But I have problems with the buttons. They just don't work.
    I'd like to do the same as in the example with a clicable list that change a multistate object.
    Is there some tips to include buttons in scrolling frame?
    Thanks for your help!
    Best
    j.

    When you paste the content frame into the container frame in the nested overlay, the buttons lose their actions. Use the Layers panel to select each button and specify the action. It helps if you give your buttons logical names like "Asparagus Button."

  • Inserting two records at the same time.

    Hi all,
    I have to check for concurrency in my application. My problem is that i cant use locks to implement it. Instead i need some logic which has to be handled at the back end that is oracle 10g so that when two records are inserted into the table, only one that came in earlier gets inserted.
    I need some logic to do so...Dose any one have some ideas.
    Regards,
    Ramit Mehra

    Use a Sequence as a surrogate (primary) key.
    What do you mean by "only one that cam in earlier gets inserted" ?
    What if there are 3 sessions attempting an insert ?
    Session "A" came before Session "B" and you reject Session "B".
    But, hey wait ! Session "B" came before Session "C" , so now you
    have to accept Session "B" and reject Session "C".
    How do you determine the "earlier" ? Do you use Date dataype or
    a Timestamp datatype ?

  • ? - Is there a way to validate 1 XML record at a time, using the SAX or oth

    Hello!
    Before running into space problems, i generated an XML file from a 'pipe delimited' file and and then processed that XML file thru a SAXParser 'validator' and the data was correctly validated, using the RELAXNG Schema patterns as the validation criteria!
    But as feared, the XML file was huge! (12 billion XML recs. generated from 1 billion 'pipe' recs.) and i am now trying to find a way to process 1 'pipe' record at a time, (ie) read 1 record from the 'pipe delimited' file, convert that rec. to an XML rec. and then send that 1 XML rec. thru the SAXParser 'validator', avoiding the build of a huge temporary XML file!
    After testing this approach, its looks like the SAXParser 'validator' (sp.parse) is expecting only (1) StringBufferInputStream as input,and after opening, reading and closing just (1) of the returned StringBufferInputStream objects, the validator wants to close up operations!
    Where i have the "<<<<<" you can see where i'm calling the the object.method that creates the 'pipe>XML' records 'sb.createxml' and will be returning many occurances of the StringBufferInputStream object, where (1) StringBufferInputStream object represents (1) 'pipe>XML' record!
    So what i'm wondering, is if there is a form of 'inputStream' class that can be loaded and processed at the same time! ie instead of requiring that the 'inputStream' object be loaded in it's entirety, before going to validation?
    Or if there is another XML 'validator' that can validate 1 XML record at a time, without requiring that the entire XML file be built first?
    1. ---------------------------------class: (SX2) ---------------------------------------------------------------------------------------------------------
    import ............
    public class SX2
    public static void main(String[] args) throws Exception
    MyDefaultHandler dh = new MyDefaultHandler();
    SX1 sx = new SX1();
    SAXParser sp = sx.getParser(args[0]);
    stbuf1 sb = new stbuf1();
    sp.parse(sb.createxml(args[1]),dh); <<<<<< createxml( ) see <<<<<<< below
    class MyDefaultHandler extends DefaultHandler {
    public int errcnt;
    "SX2.java" 87 lines, 2563 characters
    2. ----------------------------------class: (stbuf1) method: (createxml) ----------------------------------------------------------------------------
    public stbuf1 () { }
    public StringBufferInputStream createxml( String inputFile ) <<<<<< createxml(
    BufferedReader textReader = null;
    if ( (inputFile == null) || (inputFile.length() <= 1) )
    {     throw new NullPointerException("Delimiter Input File does not exist");
    String ele = new String();
    try {
    ele = new String();
    textReader = new BufferedReader(new FileReader(inputFile));
    String line = null; String SEPARATOR = "\\|"; String sToken = null;
    String hdr1=("<?xml version=#1.0# encoding=#UTF-8#?>"); hdr1=hdr1.replace('#','"');
    String hdr2=("<hlp_data>");
    String hdr3=("</hlp_data>");
    String hdr4=("<"+TABLE_NAME+">");
    String hdr5=("</"+TABLE_NAME+">");
    while ( (line = textReader.readLine()) != null )
    String[] sa = line.split(SEPARATOR);
    String elel = new String();
    for (int i = 0; i < NUM_COLS; i++)
    if (i>(sa.length-1)) { sToken = new String(); } else { sToken = sa; }
    elel="<"+_columnNames[i]+">"+sToken+"</"+_columnNames[i]+">";
    if (i==0) {
    ele=ele.concat(hdr1);ele=ele.concat(hdr2);ele=ele.concat(hdr4);ele=ele.concat(elel);
    else
    if (i==NUM_COLS - 1) {
    ele=ele.concat(elel);ele=ele.concat(hdr5);ele=ele.concat(hdr3);
    else {
    ele=ele.concat(elel);
    textReader.close();
    catch (IOException e) {
    return (new StringBufferInputStream(ele));
    public static void main( String args[] ) {
    stbuf1 genxml_obj = new stbuf1 ();
    String ptxt=new String(args[0]);
    genxml_obj.createxml(ptxt); }}

    Well,i think you can use the streaming API for xml processing provided by weblogic.It is pull model,not push model like SAX.with it,you can select the events you want without having to react to every event,and you can filter the events out.
    Sun also provide such streaming API for xml processing,and i got an very simple introduction about it on the Chinese Sun developer site.but i couldn't find any other infomation about it elsewhere! If you have such materials,please send to my email:[email protected],and if I have it,i will be sure to post the links here.hope it helps more or less:)
    @smile@

  • Full page pull out tray, pull only object workaround

    Hi,
    Is there any way yet, when creating a pull out tray/slider using the scrollable frame, to only have a object within the container pull the content, rather then being able to pull from anywhere within the container?
    Basically what I am trying to do is have a pull out that when pulled out, covers the entire page, therefore the container needs to cover the entire page which disables the ability to navigate horizontally between articles, I can still navigate vertically, but not horizontally..
    Does anyone know of a workaround that would enable me to have a full page pull out (container) and still be able to navigate horizontally. i.e. having only an object (the pull tab) pull the content rather then anywhere within the container.
    Thanks for you help
    Quinn

    Thanks everyone for your help, however I am yet to solve this problem...
    On top of the horizontally scrolling content I have created a MSO consisting of two invisible rectangle frames. Tried to see if it would work as just a MSO, nothing, turned those into a one time Auto Play Slideshow, still nothing. No matter where I pull, the content still scrolls yet I can not navigate horizontally to the next article. (Made sure I left space for the tab area, yet I can still pull from anywhere). Any other solutions/workarounds to this problem? Or if this has worked for others, possibly tell me if I am doing something incorrectly?
    Thanks again for your help.
    Quinn
    PS. I am using V20 on ID 5.5

  • Any ideas on how to control the amount of sustain pedal data that Logic Pro 9 records? Every time I press the sustain pedal down, it records 4 sustains. Same thing when I release the pedal. Thanks!

    Any ideas on how to control the amount of sustain pedal data that Logic Pro 9 records? Every time I press the sustain pedal down, it records 4 sustains. Same thing when I release the pedal. Thanks!

    This gets confusing, you have two Macs with different issues and two pedals with different issues? First let's sort out what's what. So, do the issues come from the pedals or from the Mac software? To find out, simply switch the pedals and note their behaviour. No change: it's the software, change: it's the pedals (imho the most likely scenario).
    Second, what kind of pedals are they? Can you name the type of pedal too? The Yamaha what and the Mgear which?
    Third, with the 4 fold data problem, are the doubled events simultaneous, or a few ticks apart, or more?
    Also, you have no MIDI keyboard? Are the pedals both "standalone"?
    I think you have to sort this problem at its' source, which are the pedals. You could, if push really comes to shove, perhaps create some sort of ingeneous/elaborate transformer setup in the environment to filter the extra messages, although with the 4/4 sustain events that may not even be possible. With the "stepped" events you could set up a filter to just block all events with values 20-110 or so.
    But much better would be to configure the pedal(s) correctly.

  • Pulling up duplicate records

    My custom Forms 6i application pulls up production records. However, if 2 users access the same record, the system locks one of them out. How can I display a message to the locked out user that this record has been locked by another user with that person's name?
    Also, that he has query-only access on the record till the record is released by the other user?

    on form's data block, you need to handle the lock by yourself.
    1) on-lock trigger,
    declare
    row_is_locked Exception;
    pragma exception_init(row_is_locked, -54);
    begin
    select ...into...for update ... nowait;
    /**check your lock_audit table that created first, if the current user is in, if not, insert into that table; if already in, update that table with current time and info.
    lock_record;
    IF NOT FORM_SUCCESS THEN
    RAISE FORM_TRIGGER_FAILURE;
    END IF;
    EXCEPTION
    WHEN row_is_locked THEN
    --query userinfo and alert the new user;
    2) on-update,
    put your update statement;
    3) on-error trigger,
    if error_code =40501 then
    query that audit table to alert the new user-
    It works well on my form, users cannot overwrite any thing. and was happy to see the detailed user info(including phone number and email address) who locked the record.

  • Two records getting inserted with the same timestamp...

              hi all,
              I am trying to submit a form . Now whenever I click submit before I insert any
              data sent in that form I make a check (SELECT stmt. to see if that record can
              be inserted ...few business validations..) and if the check is successful I then
              proceed for the necessary insert into a table the Primary key for which is a running
              Oracle sequence.
              But if I click on the Submit button twice in close succession I have observed
              may be 1 in 1000 attempts I am able to submit two records with the same time stamp
              for the date of insertion . We are using Oracle 8 with weblogic 5.1. And I don't
              think ORACLE's date precision is beyond seconds.
              So any suggestion ..what is the best way to handle such things : one can be
              to place the same business validation check just before the ending brace of the
              method , or secondly sucmit the form thru javascript and don't submit it twice
              even if the user clicks the submit button twice... any suggestion which u can
              give .. are welcome.
              thnx in advance
              sajan
              

    Is the pkey a timestamp or an Oracle sequence? The latter will always work,
              since no two requests to a sequence can get the same value (rollover
              excluded). If you must use timestamp, then you must auto-retry the insert
              if the first attempt fails. Oracle does have higher precision than seconds,
              but I can remember the exact precision ... I am pretty sure it works out to
              at least two or three digits though.
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              Tangosol Server: Enabling enterprise application customization
              "Sajan Parihar" <[email protected]> wrote in message
              news:[email protected]...
              >
              > hi all,
              > I am trying to submit a form . Now whenever I click submit before I
              insert any
              > data sent in that form I make a check (SELECT stmt. to see if that record
              can
              > be inserted ...few business validations..) and if the check is successful
              I then
              > proceed for the necessary insert into a table the Primary key for which is
              a running
              > Oracle sequence.
              > But if I click on the Submit button twice in close succession I have
              observed
              > may be 1 in 1000 attempts I am able to submit two records with the same
              time stamp
              > for the date of insertion . We are using Oracle 8 with weblogic 5.1. And I
              don't
              > think ORACLE's date precision is beyond seconds.
              > So any suggestion ..what is the best way to handle such things : one
              can be
              > to place the same business validation check just before the ending brace
              of the
              > method , or secondly sucmit the form thru javascript and don't submit it
              twice
              > even if the user clicks the submit button twice... any suggestion which u
              can
              > give .. are welcome.
              >
              > thnx in advance
              > sajan
              

  • How to send report output to  two  detinations at a time from command line?

    Hi ,
    how to send my report to two detinations at a time from command line i.e FILE and Mail ?
    i created batchfile in that i mentioned one line for file(DESTYPE=FILE) perpose and another line for mail perpose(DESTYPE=Mail).i don't want to mention to lines.
    i want to send my report out put two destinations at a time insted of running two times.
    thx in advance.....
    raghu

    hello,
    did you try to use distribution for that ? check out the reports distribution facilities available in 6i.
    regards,
    the oracle reports team

  • Master_detail for more than one record at a time

    Hi,
    How can i display master_detail records for more than one records at a time, for example, i have two tables A and B , A has username and role and B has username and profile. here i wanted to display 10 users at a time on my 6i form with username, role and profile.
    i have created a master-detail relation ship with these tables when i'm executing F8 on blcok A , it displays 10 records on BlockA but, only one at a time on block B, how can i display all corresponding records on block B at a time.
    Thanks for your help.Bcj

    Thanks Roberts, that was realy informative due to some doubts i would like to confirm my requirements , i have two blocks A and B and each master record has only one detail record. but i wanted to display at least 10 master_detail relationships(records) on the form at a time, i would like to know is it possible to do without creating any table or view for example,
    data in table A,
    username role
    AAA R1
    BBB R2
    CCC R3
    data in table B,
    username profile
    AAA P1
    BBB P2
    CCC P3
    i wanted to display it on form like below,
    username role profile
    AAA R1 P1
    BBB R2 P2
    CCC R3 P3
    Also would like to know that how can i select data from dba_users, any restriction is there on forms 6i, i can select it on sqlplus.
    Thanks Again, Bcj

  • Query to pull out Vendor details with AP invoice

    Hi all
    I have made the following query to pull out the following data
    House Bank Account, Customer/Vendor Name,Payment Method code,Default Account,Default Branch,Default bank Internal id,
    Document NUmber,Customer/Vendor Ref No,Row Total,Item/Service description,Branch,Street
    SELECT T0.[HousBnkAct], T1.[CardName], T0.[PymCode], T0.[DflAccount],T0.[DflBranch],  T0.[BankCtlKey], T1.[DocNum],T1.[NumAtCard],  T2.[LineTotal], T2.[Dscription], T3.[Branch], T3.[Street] FROM OCRD T0  INNER JOIN OPCH T1 ON T0.CardCode = T1.CardCode INNER JOIN PCH1 T2 ON T1.DocEntry = T2.DocEntry INNER JOIN DSC1 T3 ON T0.HousActKey = T3.AbsEntry WHERE T1.[DocDate] >=[%0] AND  T1.[DocDate] <=[%1] AND  T1.[DocStatus] = 'o' AND  T0.[PymCode] = 'EFT'
    But i have observed that i am not getting all the customers in this query where the invoice is open, it displays only few records.
    Regards
    Farheen

    Hi Farheen......
    Please try this........
    SELECT T0.HousBnkAct, T1.CardName, T0.PymCode, T0.DflAccount,
    T0.DflBranch, T0.BankCtlKey, T1.DocNum,T1.NumAtCard, T2.LineTotal, T2.Dscription,
    T3.Branch, T3.Street FROM OCRD T0 LEFT JOIN OPCH T1 ON T0.CardCode = T1.CardCode
    LEFT JOIN PCH1 T2 ON T1.DocEntry = T2.DocEntry LEFT JOIN DSC1 T3 ON
    T0.HousActKey = T3.AbsEntry WHERE T1.DocDate >='[%0]' AND T1.DocDate <='[%1]' AND T1.DocStatus = 'o' AND T0.PymCode = 'EFT'
    Regards,
    Rahul

  • My Mac Book Pro was really slow at everything and would kick me out of my photos every time i got on them. now it won't even allow me to log on. i put my password in and the screen will flash white and go back to the login page. HELP please...

    My Mac Book Pro was really slow at everything and would kick me out of my photos every time i got on them. now it won't even allow me to log on. i put my password in and the screen will flash white and go back to the login page. HELP please...

    There is nothing wrong with your Dell, it will work fine with any MacbookPro. I have been using Dell displays for over 12 years with many different Mac models. I have two 21" Ultra Sharp displays working side by side to design a Keynote presentation right now.
    The issue your having is with the way Keynote  takes control of the video output to both displays, it sends the presentation signal to one and the presenter display to the other, this is set up in;
    Keynote preferences > Presenter display.
    If you want to show a wesite or another app on  either display,  use application switcher:
    press the the  command key on the keyboard, then the tab key; a row of applications will show what applications are running, choose which one you want to show. Use command  > tab to return to Keynote.

  • Need help on filtering out one record from a report and open in new page

    Hi I am new and embarrassed to write in the forum asking silly questions. Thing is I am learning all from scratch without help from anyone. I have created a database (have previous knowledge only from Access) and have managed to create a beautiful report from a search filter. This report lines up several records matching what I needed. Now, I want to make the whole report with hyperlinks to a detailed page on each of the records in the report. I have tried using the feature where one can make one column hyperlinked and redirect to a new page, where I am getting all the records again - instead of only getting the record I am clicking on. I have looked and looked in the forums without finding solution and I have tested and tried various methods without luck. I am suspecting that I need some sort of knowledge on how to write a select query with where conditions that can apply to filtering out a record from one report to get another detailed on only one object (i.e. record). :/ Stupid or what?

    Hrefna.
    What you need to look into is two things:
    1) The link you defined, needs to set additional attributes for the target page. In the "Column Link" box, you have set the link to "Page in this Application" and followed by the page number (let's say, Page 10). Below that, you should set an Item to an item on you target page (let's call that P10_PRODUCT_ID). This item should be the primary key of your detail table (on the targe page). You can select this item from the popup list. The Value of the item should be picked from a popup list as well, being the value from the record you clicked on. This should then transfer your selected item to your page. The URL will then have something like P10_PRODUCT_ID:5 at the end.
    2) On the target page, 10, you must change the query slightly, so that it adds a WHERE clause:
    WHERE PRODUCT_ID = :P10_PRODUCT_ID
    Now, you should be set.
    Hope this helps.
    Borkur

Maybe you are looking for

  • STB jumps up one channel after Tivo recording starts

    Motorola QIP2500-3 with Standard Def Tivo box. Program is set to record on channel 50 at 9:00 PM.  Both the STB and the Tivo banner change to channel 50 and start recording, as expected. Almost immediately the STB changes to channel 51 while the Tivo

  • Workflow 2013: List does not exist error

    Hello everyone, I am creating a SharePoint Designer 2013 workflow and I encountered an error which suspends my workflow. I've noticed that it only occures when I reference a lookup column to another list. The error details that I get from the browser

  • Queries regarding the datasource to be used in the report

    Hi All, I have to use the query "0BBP_DOC_Q001" i.e "Document Flow: Shopping Cart – Purchase Requisition (Backend)".for this,what datasource should i use??? the link in help.sap.com is http://help.sap.com/saphelp_nw70/helpdata/EN/30/906e3acb8f686ae10

  • Error 2738 installing iTunes to PC

    can't find any info on what this is and how to remediate - any clues? thx

  • Keymap usage in Swing

    I've used <b>setKeyCode()</b>method of Keymap interface to trap key events in a <b>JTextField(in the keyPressed() method).</b> It's not working with Swing, but is working with AWT.(TextField) Anybody please get me the the details and its usage in Swi