The round loop records

Hi guys,.

I have a problem with that I was hoping you could help me. I have 2 blocks of data on my form. A data block always contains a record. The other contains sometimes a recording. Basically, the main data bock (car datablock) contains information about a car and the second block of data contains information about repair (repair datablock) made on this car (with a checkbox next to each repair for the user to choose if they want to). There may be none or 5 repairs to a car who knows.

One of the buttons on my form is a button continue. What I want to do before I allow the user to continue is to check if the repair data block has no record in there that is disabled. If the repairs datablock contains a total of 5 records, that I would have a loop around each and check whether it is checked or not. If it is not checked, I'll post a message. Someone here would be likely to show me how to make a loop around the second datablock to check if the box is checked.

Thank you.

There are two ways to do this. The first is to loop through the rows (as requested), and the second would be to increment/decrement a counter based on the number of lines that are enabled (this option requires you to know the total number of lines you have).

/* Option 1 */
DECLARE
   n_tot_rec  NUMBER := 0;
   n_rec_cnt  NUMBER := 0;
BEGIN
   GO_BLOCK('REPAIRS');
   First_Record;
   n_tot_rec := n_tot_rec + 1;
   WHILE (:SYSTEM.LAST_RECORD != 'TRUE') LOOP
      IF (:REPAIRS.check_box = 1 ) THEN  /* 1=Checked, 0=Unchecked */
         n_rec_cnt := n_rec_cnt + 1;
      END IF;
      Next_Record;
      n_tot_rec := n_tot_rec +1;
   END LOOP;

   /* Check if Checked = Total Records */
   IF (n_rec_cnt != n_tot_rec) THEN /* They don't match - one or more are unchecked */
      Message('All Repair records must be selected.');
      Message('All Repair records must be selected.');
      RAISE Form_Trigger_Failure;
   END IF;
END;

Option 2 is similar, but as I said, you should know how many initial records is in the block. This can be recovered to the built-in Get_Block_Property. The following example assumes that you have a component called count_checked Control_Block and you have a trigger when-box-changed add / subtracted from the count_checked element.

/* Option 2 */
DECLARE
   n_blk_cnt  NUMBER := Get_Block_Property('REPAIRS',QUERY_HITS);
BEGIN
   IF ( :CONTROL.count_checked != n_blk_cnt ) THEN
      /* There are unchecked repair records... */
      Message('All Repair records must be selected.');
      Message('All Repair records must be selected.');
      RAISE Form_Trigger_Failure;
   END IF;
END;

Note: The code is not tested. This is just to demonstrate the logic! : - )

I hope this helps.
Craig
If someone useful or appropriate, please mark accordingly

Tags: Oracle Development

Similar Questions

  • While the loop records all the data

    Hello

    I have a LabView program containing two while loops. The first is used to increment a frequency on our machine and the second, which is located in the first, used to take a certain number of points of data to this frequency. After taking these data points, the frequency is supposed to rise again. This happens for a set number of times.

    The problem I have is that the data file as the data points in the second then the loop are supposed to be written in does not display do not all the data points in the program should have taken. For example, if we want the first loop increment of 10 times and the second to take 5 data points every time, we expect to see 50 data points in our files. But we see only 10. The watch file always only an amount of data points equal to the first loop iterations. If we cut our data at that time.

    Someone has an idea what could be our problem?


  • the continuous LOOP until recording recovered

    In my stored procedure, I have a loop where to look for the file arrives on a directory. So what I need is THAT LOOP must continually search for the file and once sound generated then come out and return the results. Also, I want to have 5 minute delay, if the file creates no less than 5 minutes, then he should give the message and LOOP should end. How can I do? I tried with the next LOOP, but it did not work.

    I am using oracle 11g R2 - Enterprise Edition 11.2.0.1.

    LOOP
    Select * in table search_unique_Sequence (sys.get_dir_list('D:\temp\'|| uniqueSequence |) (("* .xml '));
    If search_unique_Sequence NULL <>
    Then
    dbms_output.put_line (uniqueSequence);
    EXIT;
    END IF;

    When I ran the SQL from the command prompt, it runs and returns the folder.
    SELECT * from table(sys.get_dir_list('D:\temp\441*.xml');

    But I need above LOOP
    1. to constantly search for file, for example 550_todaysdate.xml, and one time that the file is generated, found in a LOOP can break out of the LOOP and provide the file name
    2. in addition, if the LOOP could not find the file within 5 minutes, then end the LOOP

    Gurus: Your help is appreciated.
    Thank you

    I'd probably also put an event trigger in the process that moves the file, or a have an OS level file listener, but if you were determined to do in PLSQL, he structurally could look something like this.

       exit_loop                BOOLEAN DEFAULT FALSE;
       process_iterations       NUMBER DEFAULT 0;
    BEGIN
       WHILE exit_loop = FALSE
       LOOP
          process_iterations := process_iterations + 1;
    
          BEGIN
              SELECT * INTO search_unique_Sequence FROM TABLE (sys.get_dir_list ('D:\temp\' || uniqueSequence || '*.xml'));
    
              exit_loop := TRUE;
    
             --
    
          EXCEPTION
             WHEN NO_DATA_FOUND
             THEN
                DBMS_LOCK.sleep (30);
          END;
    
          IF process_iterations >= 10 and exit_loop = FALSE
          THEN
             exit_loop := TRUE;
             DBMS_OUTPUT.put_line ('The file never arrived.');
          END IF;
       END LOOP;
    END;
    /
    
  • The display and recording time elapsed during the reading of the instrument

    I've been programming Labview for a total of two days so please bear with my inexperience. I have a 9201 module that takes a reading of the voltage and it is plotted on a graph. I click on a Boolean switch and the graph starts playback and recording data every 3 seconds. When I click on that same switch I would like to start a clock. Then once the button is clicked once again I need to stop the clock and save time. I tried to use the elapsed timer function but can not understand how to operate inside my main while loop. I don't know if I need to use a subvi or something different all together. I enclose my any project that could make the issue easier to understand. Thanks in advance for any help.

    I changed your code (personally I him would not have made it, but I don't want too many changes in your code because you are a beginner in LabVIEW!).

    -Now, there are 2 loops: 1 bow for the acquisition (looped) and 1 loop for user interface operations (while loop + event structure: it is a very powerful structure in LabVIEW and you should take a look at a few examples to understand how it works)

    -You will find a registry to offset used by loop acquisition: I explain what it is in the diagram...

    -I gave you a VI that is almost the same as 'out of time' Express VI: maybe it will be interesting to try too understand that when you get more experience in LabVIEW (you will understand 'functional global variables' and "reentrancy execution": these 2 animals are used by 'elapsed time' Express VI (but also by the VI I've included, and which is almost the same thing))

    Note that I have shown the solution to 1 of the 4 graphs: you will need to do the same for the other 3. You also need to code elapsed time saving.

    Once again, the solution I gave you is very far from perfection, but with 2 days of practice of LabVIEW, it would be too complicated to explain the different architectures and the means of communication between the loops etc...

  • Sequence structure flat inside the timed loop and execution order

    I have some problems trying to implement a flat sequence structure when you use a loop timed on a target of cRio VI

    I tried with or without the while loop around the structure of sequence flat, and I also tried to replace the 'Non-deterministic loop' with a timed loop

    The problem is that the program seems to run only once, then get stuck somewhere

    I am writing a program that performs the following operations as soon as possible:
    1. read the Pos_MC of entry on the FPGA
    2 send the value of Pos_MC to the VI target (on cRio CPU)
    3. calculate a value of output based on Pos_MC with a PID block ("exit PID')
    4. send 'PID output' to the FPGA
    5 write "PID output" analog output "MOOG".

    In addition, I want the program to return the measured value "Pos_MC" to a host VI for the recording of data

    So that the output of PID is calculated and sent to the FPGA as quickly as possible, I placed a flat sequence structure to ensure that it happens before you send the output to the nondeterministic loop for recording data

    Also, I want the digital input 'Stop' to be able to stop the loop deterministic (the timed loop)

    I read much more entries than that and the help of several PID and exit, but I rewrote the code for a single entry and exit to make it easier to illustrate

    Screenshot of the code is shown in 'target code.png' and 'fpga code.png.

    The VI themselves are attached in the next post (cannot attach files of more than 3)

    Question 1:
    Any advice on how to get this race? Thank you!

    Question 2:
    Is also my correct understanding in that, using this structure, each 0.9ms (fpga loop time) comes the following:
    1. the input ("Pos_MOOG") is read on the fpga
    2. the production of PID is calculated on the cRio with some delay to computation (for example 0.1ms)
    3. the output of PID is then written for analog output "MOOG" in all about 0, 1 - 0.2ms
    4. the FPGA program then waits until 0.9ms spent and repeat the process

    As opposed to the next pass whenever performing a loop is started on the FPGA:

    1. the FPGA reads the input and written on the output (the output of the execution of the previous loop PID)

    2. then the entry is sent the cRio, PID output is calculated and sent to the FPGA

    3. the new release of PID is maintained until the next time through the loop

    Thank you!

    PHG wrote:

    Thanks for the input guys, any advice as to how I could get the feature in scenario 1?

    I still say that the best route is just putting all the logic of the control in the FPGA.

    Other alternatives include 1) the use of DMA FIFO sedn data back or 2) use interruptions so that the FPGA code can not read the output level until the RT.

    DMA FIFOs are usually very limited, and I would not use them in this situation since I belive said it this code to do for the many outputs.

  • LV fpga - wait express vi slows down the other loops?

    Hi all

    I have a question about the use of the vi wait Express in Labview FPGA. I use 2 loops, one that changes data, the other records it these data by sending it to a FIFO. In the first loop, I change the value of a variable named "CurrentWfmFast?" from true to false. After that, I use the vi wait Express to wait a few microseconds, so the program does not change this value to true immediately. In the second loop, I connect the data a FIFO to send to the host.

    If I now draw the variable in the host.vi, it seems that the value of the "CurrentWfmFast"? has changed AFTER the vi wait Express instead of before (see attachment).  If I change the wait ' (we) Pos Stable ' to 60000, for example, the value of "CurrentWfmFast?" changes after 60000 US... How is that possible? What is the vi wait another Express while loops influence?

    Thank you in advance,

    Best regards
    Dries

    I finally thought to it myself. Before that the value of "CurrentWfmFast?" went from true to false, the waiting already executed only once. That's why the value has not changed immediately. Instead of 1 wait, there are 2, that was my mistake.

    I know it has been difficult (if not impossible) for you to understand that without the whole project, but thanks for watching it. If I need more help, I'll post the VI or the entire project.

    Best regards

    Dries

  • How is it my local variable is not updated its value compared to what is happening in the while loop?

    Hello

    I am trying to extract data from a time that my statements updated in what concerns the number of loop iteration. I tried to use the two local variables and travel records, but without success.

    I also did the following example: http://www.ni.com/white-paper/7585/en and it works like a charm.

    I've attached the PNG file with declaration of the local variable circled in red. Join a VI in the next respnose.

    Thank you

    No, the two while loops are stacked and not parallel, which means the outer loop cannot go to the next iteration until all code in this document, including the inside so that the loop is finished.

  • loop nested using iteration of the outer loop as counter

    Hello world.  I have a moment where I perform calculations at each iteration of the loop and display on the front panel.  Then, in a loop iteration randomly (referred to here as I = 9 to test) it fires an event where that performs calculations on x number of iterations (iterations of the outer loop while) the result of external calculations, while performing at the same time and the view from the outside so that the calculations of the loop.  Is that two mathematics algorithms are synchronized in iterations.  After x iteration the program returns then to only calculate and display the while loop calculations using the value from the shift register, updated until another event is triggered (I do not show an another event trigger in the code example) I can just find a way to trigger an event , and at the same time to make two calculations with the same loop iterations.  Any suggestions?

    The VI of the sample in the previous post of crossrulz should provide the functionality you are looking for. The while loop acts to go through ten operations you want to perform and records time difference will allow him to record these values, as you understand. I think that crossrulz refers to shift registers on the while loop that surrounds the case structure that records the shift are unusable on a structure of the case, as you pointed out.

  • Oracle 11g: engage inside the outer loop or loop

    Hello

    Could someone pls help in this regard.

    My PLSQL program retrieves approximately 400 000 thousand records in cursor loop and cl, it takes more than 4 hours to complete IT.

    I commit every transactions inside the cursor loop... This can affect the runtime performance?


    Also, pls suggest, can we use commit 400 000 transactions once it will be faster? (or) the performance of baskets longer than the current situation.


    My goal is to make the fastest program and expect to reduce the timing of execution of 4 hours to 1 hour...


    Appreciate your help...


    Program design: advice:

    a. Select 400 000 thousand documents in the cursor.

    b. inside cursor for loop to two new sql instructions written to get values and store it in the local variable (this value is used in the call to insert data), two sql statements are handled with no_data_found and too_may_rows logic implicit sql statements to intercept the errors of the company

    c insert statement.

    validation of d. inside the loop (batch mode: nowait)

    management at the level of the procedure using raise_application_error exception e...

    Do not use the PL/SQL for data processing. SQL is a powerful language. Get the best out of him.

    Here is an example of using INSERT ALL. This is untested code and may contain syntax and semantic errors.

    insert all
      into medicomread.aatable_permit_people
      (
            permitnum
          , lic_num
          , lic_type
          , bus_name
          , addr1
          , addr2
          , addr3
          , city
          , state
          , zip
          , ph1
          , ph2
          , fax
          , bus_lic
          , lic_original_issue_date
          , expiration_date
      )
      values
      (
            appt_ref_no
          , lic_num
          ,'Business License'
          , company_name
          , postal_address
          , null
          , null
          , null
          , emirate
          , po_box
          , telephone
          , null
          , fax
          , license_no
          , issue_date
          , expiry_date
      )
      log errors into err$_aatable_permit_people ('INSERT1: HEALTH CARD SPONSOR DETAILS') reject limit unlimited
      into medicomread.aatable_permit_people
      (
            permitnum
          , tt_contact_type
          , name
          , b1_contact_nbr
      )
      values
      (
            appt_ref_no
          , 'Applicant'
          , cname
          , userseqno
      )
      log errors into err$_aatable_permit_people ('INSERT2: HEALTH CARD BUSINESS USER DETAILS') reject limit unlimited
      into medicomread.aatable_permit_people
      (
            permitnum
          , tt_contact_type
          , B1_Contact_Nbr
          , Name
          , gender
      )
      values
      (
            appt_ref_no
          , 'Individual Health'
          , userseqno
          , patient_name
          , ***
      )
      log errors into err$_aatable_permit_people ('INSERT3: HEALTH CARD APPLICANT USER DETAILS') reject limit unlimited
    with t1
    as
    (
     select mr.appt_ref_no
          , mr.sponsor_name
          , substr(mr.PATIENT_NAME,1,79) PATIENT_NAME
          , mr.***
       from medicomdata.mc_register mr
          , medicomdata.mc_process_type_register mptr
          , medicomdata.um_users uu
          , medicomdata.um_companies uc
      where mr.patient_id     = mptr.patient_id
        and mr.pro_id         = uu.user_id
        and mr.facility_id    = mptr.facility_id
        and mr.process_type   ='OH'
        and mr.regn_status    = 5
        and mr.sponsor_name   = uc.company_name
        and uu.type_id        = 3
        and (add_months( mptr.issued_date, 12 )-1) > sysdate
    ),
    t2 as
    (
     select decode(ucr.license_category_id,'DED','DED'||uuc.license_no,uuc.license_no) lic_num
          , uuc.company_name
          , ucr.postal_address
          , ucr.emirate
          , ucr.po_box
          , ucr.telephone
          , ucr.fax
          , uuc.LICENSE_NO
          , ucr.issue_date
          , ucr.expiry_date
       from medicomdata.um_companies uuc,medicomdata.company_registration ucr
      where uuc.license_no=ucr.business_license_number
        and uuc.inactive=0
        and upper(ucr.request_status)=upper('true')
    ),
    t3 as
    (
     select uu.company_name
          , cname
       from (
             select uu.first_name ||' '|| uu.last_name cname
                  , row_number() over(partition by uu.company_name order by decode(usr.service, 'HCDC', 0, 1)) rno
               from medicomdata.um_users uu
                  , medicomdata.user_service_request usr
              where uu.user_id      = usr.user_id
                and usr.service     = 'HCDC'
                and uu.type_id      = 2
                and uu.inactive     = 0
             )
      where rno = 1
    )
    select t1.appt_ref_no
         , t1.patient_name
         , t1.***
         , t2.lic_num
         ,'Business License'
         , t2.company_name
         , t2.postal_address
         , null
         , null
         , null
         , t2.emirate
         , t2.po_box
         , t2.telephone
         , null
         , t2.fax
         , t2.license_no
         , t2.issue_date
         , t2.expiry_date
         , t3.cname
         , companyuserseq.nextval userseqno
      from t1
      join t2
        on t1.sponsor_name = t2.company_name
      join t3
        on t1.sopnsor_name = t3.company_name;
    
  • How to measure the speed of the funnel without the closed loop of the report?

    We seem to be in trouble, we want to move to 10 Eloqua and/or get the closed loop, tool of reporting, but we have to wait. However, we still really need to be able to measure our funnel and speed into the funnel. So did he do this without the help of eloqua fancy reporting tools?

    To calculate the speed you need two things:

    (1) steps defined

    (2) a date stamp for each step, you're trying to follow a long time.

    I've seen customers calculate the funnel using their CRM speed by writing a date to a field on the contact record and then report on these dates.  For global directional numbers I've seen customer on created lead report / month, then had a date on the contact record to identify SAL in a period of time, following by pointing out the standard option.  This is not one to one, but can provide valuable guidance.  To be precise and complete the picture, you would need MQL dates and SAL on the contact record, and your opportunity process will need to have associated contacts.

    On the product side, income Suite is available on E9.  No need to wait.

  • ID CC2015 (MacOSX 10.9.5) data merge splitting script - "data are out of reach,"... for the first 99 records?

    Hi all.

    Scripter Hans Haesler has created a script that I'm sure that a lot of people involved in the merger of data would consider a 'must - have' - the ability to individually named indesign files merging data records (create hyperlinks with script, without a large increase in size and treatment of the BP reqs resulting?). It has improved this script by adding the ability to change the name of the files to the results of a particular field in a database (http://www.hilfdirselbst.ch/foren/INDesign_Script_f%FCr_Datenzusammenf%FChrung_P513807.htm l).

    I took his script and does four things to him:

    • CSV splitter now a tab rather than a comma (to use text files delimited by tabs, rather than the files variables separated by a comma);
    • Fixed to be cross-platform CheminDossierCible (wasn't working properly on my mac);
    • fixed a catastrophic bug that could use the assignment information from file names text referenced in the open file dialog box, but the merger of another data base that has been already linked in the file, so added myDoc.dataMergeProperties.selectDataSource(csvFile,) to ensure that myDoc uses the same data file that is called by the File.openDialog;
    • rather than exporting an InDesign file, this operation exports a PDF preset.
    var fileNameColumn = 1;//Insert here the column number in the CSV of the new file name is specified. 
    var csvSeparator = '\t'//Please here the separator of CSV file Enter 
    var destFolderPath = Folder.selectDialog('Destination Folder for PDF files').fsName + '/' ; 
    var csvFile = File.openDialog('select CSV file'); 
    
    //CSV import 
    var fileNames = new Array(); 
    csvFile.open('r'); 
    while (!csvFile.eof) { 
       fileNames.push(csvFile.readln().split(csvSeparator)[fileNameColumn-1]); 
       } 
    csvFile.close(); 
    
    var myDoc = app.activeDocument;//prepared document  
    myDoc.dataMergeProperties.selectDataSource(csvFile,);
    myDoc.dataMergeOptions.removeBlankLines = true;
      
    var maxRange =  myDoc.dataMergeProperties.dataMergePreferences.recordRange.split('-')[1];//Number of records in the CSV  
    //Loop through the records  
    for(var  i = 0; i < maxRange; i++)  
       {  
       with(myDoc.dataMergeProperties.dataMergePreferences)  
          {  
          recordSelection = RecordSelection.ONE_RECORD;  
          recordNumber = i+1;
          }  
       myDoc.dataMergeProperties.exportFile((destFolderPath + fileNames [i+1] + '.pdf'), "[High Quality Print]", );
       } 
    

    The best thing - IT WORKS! Well, it does, but something very strange happens. If the database is 99 records or less, the script will be run end until it finishes processing the last record and then this dialog appears:

    Screen Shot 2015-07-10 at 11.38.29 pm.png

    If the database is 100 records or more, then the script works very well and no warning appears. Despite the files PDF export properly, present a defect is the only thing that keeps me from being happy with the script. It's like having a sports car which turns around when he touches out of ignition, unless its duct more than 100 km and then it not to do so.

    For once, I am convinced that the script is written correctly, but I can't work on why this error occurs. Is this a bug in the template script ID, or I missed something? Or is this a bug on my computer only? Is anyone able to attempt to reproduce the fault on their own machine?

    Thank you very much

    Colin

    Never mind colleagues posters, I solved my problem.

    From what I can tell, the InDesign is keep in memory the table from the script the first time, it has been run. Not even

    fileNames.length = 0;

    at the end of the script's force at first.

    Way the easiest way is to set a backup statement just before the beginning of the script.

    myDoc.save (myFile);

    and then, at the end of the script, force the script to close the merge file without saving the changes, but open it back to the top

    myDoc.close (SaveOptions.no);

    myDoc = app.open (myFile);

    I tried

    myDoc.revert

    but he keeps setting up a dialog box asking "Are you" sure and I don't see anything in

    Adobe InDesign CS6 (8,0) object model JS: Table of contents

    or

    http://www.indesignjs.de/extendscriptAPI/indesign10/

    that a property to force a return to actually return without the dialog box.

    Regardless, the result is the same – the document close, open and returned to its original state. So far, it seems to work... yay!

  • How do 'Loop recording' in CS6

    I can find how define 'Loop while recording' (salt or view) that was available in CS3 by right clicking the record button.

    I tried setting the 'repeat' has no effect when you are recording a track.

    CurrentY when I press the record button it starts recording of the selected range in the track then STOPS.

    He did not return to the beginning and continue to record another file.

    I need to record streaming multiple files in a selected range.

    for example my vocal booth is on l ' of the piece that is on the computer.

    When I got CS3 it's simple record five takes both in a loop of record.

    WHAT ME MISSING HERE?

    @Ronin: I can't help but notice most, if not all of your answers state: "..." Search for an alternative DAW'. I guess Adobe should rename hearing to "Adobe Audition for TV/Radio, but no music CCXX.

    I now regret having upgraded from CS3 to CS6.

    The main part of "Loop recording while' must be hands free. for example save 5 solo lead in a loop for you can choose the one that suits. The ability to not touch the mouse or keyboard to reset the record button while your having a guitar in your hands is very useful. Why anyone would remove it is beyond me.

    Do not 'Loop while recording' confused with loops (repeat structure). Your suggestion of copy and paste is not what we are talking about here.

    I'll never RENT hearing on the cloud, so my only solution is to pester "Apple" out a Windows version of 'Pro Logic' (if all goes well for $200 or less) that take advantage of the Mac user (no rent for life, but you admit it).

  • Place the missing documents in the list of records with a rank value

    Hi all

    I have this table:
    WITH taba AS (SELECT 99 AS id,
                         '2011-08-08' AS date_ini,
                         10 AS VALUE,
                         1 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 99 AS id,
                         '2011-09-08' AS date_ini,
                         11 AS VALUE,
                         2 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 99 AS id,
                         '2011-10-08' AS date_ini,
                         10 AS VALUE,
                         4 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 999 AS id,
                         '2011-08-08' AS date_ini,
                         10 AS VALUE,
                         1 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 999 AS id,
                         '2011-09-08' AS date_ini,
                         10 AS VALUE,
                         2 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 999 AS id,
                         '2011-10-08' AS date_ini,
                         10 AS VALUE,
                         3 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 9999 AS id,
                         '2011-08-08' AS date_ini,
                         10 AS VALUE,
                         2 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 9999 AS id,
                         '2011-09-08' AS date_ini,
                         15 AS VALUE,
                         3 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 9999 AS id,
                         '2011-10-08' AS date_ini,
                         10 AS VALUE,
                         4 AS RANK
                    FROM DUAL)
    SELECT *
      FROM taba
    And I need to return the same results but with the addition of records that have no rank. For new records the VALUE must always be zero (0) and the value of DATA_INI must have the same value as the order of the records immediately following. Just like that:
    99       2011-08-08     10     1
    99       2011-09-08     11     2
    *99       2011-10-08     0     3*
    99       2011-10-08     10     4
    999      2011-08-08     10     1
    999      2011-09-08     10     2
    999      2011-10-08     10     3
    *9999     2011-08-08     0     1*
    9999     2011-08-08     10     2
    9999     2011-09-08     15     3
    9999     2011-10-08     10     4
    I can do this using a loop procedure, but I want a filter query. ;)

    Thanks in advance.
    Filipe Almeida

    Hi, Felipe,.

    So, you want multiple copies of a few lines. In other words, if a value or rnk (RANK is not a column name right) is missing in a given id you want to with the next highest rnk and the same id line repeated 2 or maybe even several times. All copies will be identical, except that rnk will have the missing numbers, and the value will be 0 on all additional copies.

    A way to do that is to join your table (or something very similar to it, as in the example below) to a Meter of Table , which is a table (or a result set, in this example) counts 1, 2, 3,... up to however many copies may be required.

    WITH     got_rows_needed          AS
    (
         SELECT     id, date_ini, value, rnk
         ,     rnk - LAG (rnk, 1, 0) OVER ( PARTITION BY  id
                                                ORDER BY          rnk
                                )         AS rows_needed
         FROM    taba
    )
    ,     cntr               AS
    (
         SELECT     LEVEL - 1     AS n
         FROM     (
                   SELECT     MAX (rows_needed)     AS max_rows_needed
                   FROM     got_rows_needed
              )
         CONNECT BY     LEVEL <= max_rows_needed
    )
    SELECT    r.id
    ,       r.date_ini
    ,       CASE
              WHEN  c.n  = 0
              THEN  r.value
              ELSE  0
             END               AS value
    ,       r.rnk - c.n          AS rnk
    FROM       got_rows_needed  r
    JOIN       cntr             c     ON  c.n  < r.rows_needed
    ORDER BY  id
    ,            rnk
    ;
    

    By elsewhere, store date information in a VARCHAR2 column, such as date_ini, is a very bad idea. Use a DATE column.

    Published by: Frank Kulash, August 8, 2012 11:02

    RANK is a keyword from Oracle. (It is the name of a built-in function). If you specify your own columns of RANK, it will confuse people reading the code, and it can result in compiler errors, too.
    ID is also an Oracle keyword. To be sure, you can use another name, such as grp_id, instead of id.
    It is best not to name your own objects with any name of fArrondi in v$ reserrved_words.keyword.

  • to find the number of records retrieved in the select statement in the cursor

    Hi all
    with the cursor, I'm selecting select statement together and writing in the .txt file.
    his worksheet, but it should not open the file, if the cursor returns nothing.
    How to find the number of records returned by the select statement in the cursor.
    pls help me.

    Thank you...

    Don't understand what you're trying to say, but maybe it's...

    DECLARE
       vCounter NUMBER;
       -- Other variables...
    BEGIN
       vCounter:=0;
       FOR .. IN cursor LOOP
        IF vCounter=0 THEN
          -- Here open file...
          -- Here write one time data...
        END IF;
        -- Here write cursor data...
        vCounter:=1;
       END LOOP;
    END;
    

    -Clément

  • Query to get the number of records

    Hi all

    I would get the number of records in all tables in a schema. I don't want to run select count (*) of < table name >, because there are nearly 400 paintings. So I need a generic quqeyr that will give the recordcount for all tables.

    Experts good help yourslef to tide me over.

    Do you need a specific account? Or an approximate count is sufficient? Do you use the RBO and CBO?

    If you use the CBO and want an approximate count, column NUM_ROWS USER_TABLES should give you what you want.

    If you need a specific account, you will have full scan all tables. You can automate this process via SQL dynamic, i.e.

    DECLARE
      l_cnt INTEGER;
    BEGIN
      FOR x IN (SELECT table_name FROM user_tables)
      LOOP
        EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || x.table_name INTO l_cnt;
        dbms_output.put_line( 'Table ' || x.table_name || ' has ' || l_cnt || ' rows.' );
      END LOOP;
    END;
    

    Lawrence was also a [solution based on XML Query | http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html] to count all the rows in each table in a schema.

    Justin

Maybe you are looking for

  • Service event of Chanel

    Hi all I have a dataset using two channels: (1) a signal that has Boolean values (0/1) and (2) times. I want to eliminate this signal noise, I mean what gives a value of 0 for the signals that last less than 2 minutes. I guess first of all, I must ca

  • Files replaced by unrecognized versions. CD is the wrong CD

    original title: "FILES REPLACED BY UNRECOGNIZED VERSIONS. CD IS THE WRONG CD.  INSERT WINDOWS XP PROFESSIONAL CD2 INTO THE CD PLAYER. "I DON'T HAVE THIS CD." ACK 3, VERSION 2002 ON the computer PORTABLE DELL "INSPIRON MXCO61 988 MHz, and 504 MB of RA

  • Shut down Windows takes longer than 3 minutes

    Separated from this thread. When I stopped in Windows 7 the "Shutting Down" screen stays on for more than three minutes. I tried to start in safe mode, but I get the same result. I tried to disable third-party programs and get the same result. It's a

  • Telepresence Reporting

    Someone has some good ideas around telepresence Reporting I think that one of the key elements missing is this.

  • I can't validate Windows 7 the link on my computer does nothing

    After replacing the motherboard on my computer, I noticed that windows needs to be valid re When I go to the link and pass my mouse over it it changes color, but has no action or doesn't make any sound when I click my mouse. the timer countdown with